System.Text.RegularExpressions Class

  • Thread starter Thread starter chris fink
  • Start date Start date
C

chris fink

Using regular expression testers such as Expresso or Dan Appleman's tester,
I have a regular expression that tests fine and is returning matches.
However, when the same regex is run through code, the same code that is
returning the matches in the tester, no matches are found. The only
difference is that the in the tester, the source to run the regex against
are placed into a texbox (string array) and in the code the source is
generated from a web request into a string object.

Has anyone had any similar issues?

Thanks
Chris
 
Hello,

chris fink said:
I have a regular expression that tests fine and is returning matches.
However, when the same regex is run through code, the same code that is
returning the matches in the tester, no matches are found. The only
difference is that the in the tester, the source to run the regex against
are placed into a texbox (string array) and in the code the source is
generated from a web request into a string object.

Post some code.

Regards,
Herfried K. Wagner
 
Hello Herfried,

I'm having the same problem and it's driving me crazy. This code does
not work when run but works in 2 expression evaluators.

Chris

Sub test()
Dim testString As String = "Me.Button1.Name = 'Button1'"
Dim regVars As New Regex( _
"(?:^\s*)(?<name>.*)\s*=\s*(?<value>.*)(?=\r\n)", _
RegexOptions.IgnoreCase _
Or RegexOptions.Multiline _
Or RegexOptions.Compiled _
)
Dim regMC As MatchCollection = regVars.Matches(testString)
If regMC.Count > 0 Then
MsgBox("Success")
End If
End Sub
 
Back
Top