I have been given some poorly formatted data and need to pull numbers out of strings. I’m not sure what the best way to do this is. The numbers can be any length.
string a = "557222]]>";
string b = "5100870<br>";
any idea what I can do so I’ll get this:
a = "557222"
b = "5100870"
Thanks
Solution is for c# sorry. Edited the question to have that tag
Not familiar enough with .NET for exact code. Nonetheless, two approaches would be:
21389abc), this is the easiest.1231a23v) and want to keep every digit, use the regex[^\d]to replace non-digit characters.