views:

37

answers:

2

Hi!

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 string 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;
A: 

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.

Russ C
`"\r"` does not work in *Visual Basic* IIRC.
KennyTM
Indeed, that didn't work :(
Eric Lachance
Updated my answer, just in case. Try the regex with vbCr and \r too.
Russ C
Nope, none worked.One thing that does work is this:`regexp.pattern = ".;"`The only issue is that it would detect other htmlcodes starting with 1 which may or may not be an issue (I don't use HTML code anywhere else afaik).
Eric Lachance
can you post a snippet from your watch window or something of what strText actually contains ?
Russ C
Done, added sample.
Eric Lachance
Answer updated.
Russ C
Russ, "only works in IE" = fail. I mention WSH, meaning I am not using a browser, I am doing this from a command line (a .vbs file). There are notable differences between both. Possibly this is one of them.
Eric Lachance
I was referring to the vbscript example link, the Regex options I mentioned should work in a .vbs file.
Russ C
A: 

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.

Eric Lachance