[RESOLVED] Looping Regex Match Collection
Hi Guys,
I have my regex setup, which works prefectly:
code:
vb.net Code:
Dim testStr As String = "<option value=""18621335"">graham23s</option>"
Dim rx As New Regex("\<option value=""(\d+)""\>(.+?)\<\/option\>")
MsgBox(rx.Match(testStr).Groups(1).Value)
MsgBox(rx.Match(testStr).Groups(2).Value)
When i put it into my own application i have done:
code:
vb.net Code:
Dim stringSource As New Regex("\<optionvalue=""(\d+)""\>(.+?)\<\/option\>", RegexOptions.IgnoreCase Or RegexOptions.Singleline)
Dim stringMatches As MatchCollection = stringSource.Matches(stringClean)
For Each stringsMatch As Match In stringMatches
Next
what i am having trouble with is getting the values while in the foreach loop, any help would be appreciated.
thanks a lot guys
Graham
Re: Looping Regex Match Collection
solved it! thanks guys
Graham
Re: [RESOLVED] Looping Regex Match Collection
vb.net Code:
Dim stringSource As New Regex("\<optionvalue=""(\d+)""\>(.+?)\<\/option\>", RegexOptions.IgnoreCase Or RegexOptions.Singleline)
Dim stringMatches As MatchCollection = stringSource.Matches(stringClean)
For Each match As Match In stringMatches
stringsMatch1 = match.Groups(1).Value
stringsMatch2 = match.Groups(2).Value
Next
Re: [RESOLVED] Looping Regex Match Collection
Thanks pradeep! thats better than what i had :)
Graham