get numbers from string using Regular Expressions Vb.net
/get numbers from string VB.NET
Suppose
String is Alphanumeric, if user wants to extract Numbers only, in that
case you can use Regular expressions to match digit patterns.
for ex: String str = "1abc34bcd677bsgdb7878ddh63d4d";
output:
1
34
677
787
63
4
34
677
787
63
4
Regular Expression for matching digit is "\d", + means one or more digits(\d ).
Dim str As String = "1abc34bcd677bsgdb7878ddh63d4d"
Dim mc As MatchCollection = Regex.Matches(str,"\d+")
Dim i As Integer
For i = 0 To mc.Count- 1 Step i 1
Console.WriteLine(mc(i).Value)
Next
End Sub
Note: One way of getting Numbers from a String
Tags:get numbers from string VB.NET Regular Expressions,
get
numbers from string VB.NET,Regex.Matches.MatchCollection,Integer Arrays
VB.NET,Regular Expression Pattern matching digits only.
No comments:
Post a Comment