views:

56

answers:

1

I have an issue where I need to find a string in a file, but when I run the regex.match function it returns the string without any text between "<" and ">" missing. Here is my code and the string returned

Original string - [$iif{len("Test")>0,<meta name="Author" content="Test">,""}$]

regex Pattern - \[\$[a-zA-Z_0-9\{\}\(\)<>=\|/\."",\s]*\$\]

result - [$iif{len("Test")>0,,""}$]

'Visit http://msdn.microsoft.com/en-us/library/ms974570.aspx for explanation on this reg expression 
regex.pattern = "\[\$[a-zA-Z_0-9\{\}\(\)\<\>=\|/\."",\s]*\$\]"

set matches = regex.execute(psTemplateData)

for each m in matches
    response.write m & " index - " & m.FirstIndex  & " " &  m.length & "<br />"
next

What is funny is that the match has the correct string length for the original string. Thanks in advance for any help.

Wade

+1  A: 

The regex seems fine. My guess is your browser shows you [$iif{len("Test")>0,,""}$] because the <meta name="Author" content="Test"> portion is being interpreted as HTML and thus disappears.

You'll need to encode the output so those angle brackets become &lt; and &gt;. Look at the Server.HTMLEncode method.

Ahmad Mageed
That was it, sometimes it doesn't pay to get out of bed. Thanks.
Wade73