开发者

How do I remove &#13 ; 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>&#13;
<ul><li>&#13;
<p>In the <strong>Document </strong>properties dialog box, [clip].</p>&#13;
</li>&#13;
</ul></li>&#13;
<li>&#13;
<p>Click <strong>OK</strong>.</p>&#13;
</li>&#13;
</ol><p><span>To add or edit an advanced paper handling operation: </span></p>&#13;
<ol><li>&#13;
<p>To add an operation, [clip] </p></li></ol>&#13;


I'm surprised strText = Replace(strText, "&#13;", "") 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 "&#13;" 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 = "&#1.;" , which of course will also detect other instances of HTML codes in that format - but in my case this works fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜