Regular Expression Help in .NET
- by Matt H.
I have a simple pattern I am trying to match, any characters captured between parenthesis at the end of an HTML paragraph. I am running into trouble any time there is additional parentheticals in that paragraph:
i.e.
If the input string is "..... (321)</p" i want to get the value (321)
However, if the paragraph has this text: "... (123) (321)</p" my regex is returning
"(123) (321)" (everything between the opening "(" and closing ")"
I am using the regex pattern "\s(.+)</p"
How can I grab the correct value (using VB.NET)
This is what I'm doing so far:
Dim reg As New Regex("\s\(.+\)</P>", RegexOptions.IgnoreCase)
Dim matchC As MatchCollection = reg.Matches(su.Question)
If matchC.Count > 0 Then
Dim lastMatch As Match = matchC(matchC.Count - 1)
Dim DesiredValue As String = lastMatch.Value
End If