I have a RegEx I am using in vb.net and i can get all the matches of the text but i want to get the first match of the text, this is what i am using.
Text: :1283 xxxxxxxxxx :1288 :9879
RegEx: :[0-9]+
How do i just get the first match (:1283)?
The code i am using is:
Dim MRIDRegex As New Regex(":[0-9]+")
Dim count As Integer = 0
Dim mrid As String = String.Empty
For Each item As Match In MRIDRegex.Matches(message)
count += 1
If count = 1 Then
mrid = item.Value
End If
Next
I searched on Google for vb.net regex match, and this was the first result. This is the code sample they used.