Given a string with a numeric value in it, I need to extract that value and assign it to a variable. I use the following to accomplish that:
Dim m as Match = Regex.Match(str, "\d+")
If m.Success Then
test = m.Groups(0).Value
End If
It works fine for string like this one:
This is a 4308 number
I get 4308 extracted. However, if the numeric value contains commas or dots:
This is a 4,308 number
Then, the value extracted is 4 instead of 4,308 or 4308.
How can I modify my regular expression to retrieve the whole number whether or not it contains commas and/or dots?