Regex to find a number in a string in

Posted by Ranjeet_8 under VB.NET category on | Points: 40 | Views : 1405
Find a number in a string

Imports System.Text.RegularExpressions

Dim regex As New Regex("\d+")
Dim match As Match = regex.Match("Ranjeet_8")
Dim Mval As String = ""

If match.Success Then
Mval = String.Format("Number found: " + match.Value & " at position " & match.Index.ToString())
Mval = "Not found!"
End If

Comments or Responses

Login to post response