how to remove all non-digit characters from a string

  • Thread starter Thread starter Zeng
  • Start date Start date
Z

Zeng

Hello,

Is there a way to remove all non-digit characters from a string in one call?
string.Replace() methods don't allow this.

thanks!
 
Use regex

--
Regards,
Tamir Khason
Especially those days you need a flexible IT service provider that can meet
your needs through a broad set of offerings.
TCON - A technology company that understands your business.
www.tcon.co.il
 
string s = Regex.Replace(oBox.Text,"\\D","")

or "\\d" one means digit the other one means non digit. i forget at the
moment which is which.
 
Yeah, I flip back and forth between C# and VB.NET a lot, so I always code
like the other one for the first few hours. Someday I'll remember it @.
 
Back
Top