Regex removes code from between "<" and ">"
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,,""}$]
开发者_StackOverflow社区'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
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 <
and >
. Look at the Server.HTMLEncode
method.
精彩评论