Extract first sequence number in string

'Var textin As String = "AB3225JZTHG "
Var re As New RegEx
re.SearchPattern = "\\d+"

Var match As RegExMatch = re.Search(textin)

If match <> Nil Then
  Return match.SubExpressionString(0)
Else
  return "-"
End If

I pass this function a string and I want to extract the numeric part (or first numeric sequence), but it always just returns the ‘-’. Input parameter is textin, return is a string.

It may be a long day but have I missed something blindingly obvious. If I pass AB3225JZTHG I want the ‘3252’. In debug mode the function shows the string, but a match is always nil and as such returns ‘-’.

Thanks in advance.

Your pattern has one too many “\” in it. :grin:

Thanks Eric, you are correct. I clearly have a lot to learn about the mystical art of regex :grinning_face: