Easy method for extracting numeric portion of string?

  • Thread starter Thread starter DevDave
  • Start date Start date
D

DevDave

Does anyone know of a quick method to extract just the numeric portion
of a string without looping through each character?

For instance:

674h23i -> 67423
23-112 -> 23112
87 (21) -> 8721

Thanks,
David
 
Thanks,

I forget how quick and easy RegEx can be.
Here's what I used:

Regex.Replace(myString, "\D", "")


David
 
Back
Top