Best way to get all digits from a string
Have you got something against Replace
?
return Regex.Replace(input, @"[^0-9]+", "");
Do you need to use a Regex?
return new String(input.Where(Char.IsDigit).ToArray());
Have you got something against Replace
?
return Regex.Replace(input, @"[^0-9]+", "");
Do you need to use a Regex?
return new String(input.Where(Char.IsDigit).ToArray());