How do I remove 
 ; from my text file using VBScript Replace() or a regex?
I'm doing a conversion between two software which both use XML so the actual conversion part is fairly straightforward - adding text here, removing others here, converting a few information. I'm using VBSCript WSH.
The only issue I'm still having is the darn
character - because it's considered an HTML Character, it's not detectable as a string, even though it's a string...
I've tried both strText = Replace(strText, " ", "")
and using a regex with Regex.pattern = " "
... neither works. I also tried replacing char(13)
, VBCR
... nothing seems to detect the actual st开发者_StackOverflowring itself and not the character it's creating.
Code Snippet from incoming file:
<p>If necessary, [clip].</p>
<ul><li>
<p>In the <strong>Document </strong>properties dialog box, [clip].</p>
</li>
</ul></li>
<li>
<p>Click <strong>OK</strong>.</p>
</li>
</ol><p><span>To add or edit an advanced paper handling operation: </span></p>
<ol><li>
<p>To add an operation, [clip] </p></li></ol>
I'm surprised strText = Replace(strText, " ", "")
doesn't work, and the regex should be ok too.
Can you try setting these options
Regex.IgnoreCase = True
Regex.Global = True
I used this test page and just setting the pattern to be " "
worked fine:
http://www.regular-expressions.info/vbscriptexample.html
This only works in IE, by the way.
A workaround to all of this is to use: regexp.pattern = ".;"
, which of course will also detect other instances of HTML codes in that format - but in my case this works fine.
精彩评论