Say I have a string containing numbers and other chars.
I want to reduce the string to numbers only.
F.e. from 23232-2222-d23231 to 23232222223231
Can this be done with string.replace()?
if not, what's the simplest and shortest way?
10x!
There are a bunch of possibilities, from Regular Expressions to handling the text yourself. I'd go for this:
Regex.Replace(input, @"\D+", "")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With