Regular expression to get only numbers from string

you can also replace anything else except numbers with nothing, which will give you a plane number string that can be converted into an integer. Syntax below

System.Text.RegularExpressions.Regex.Replace(“strTextTobBeTreated”,“\D”,“”)

make sure to add the namespace System.RegularExpressions

2 Likes