how to remove all non-digit characters from a string

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!
 
T

Tamir Khason

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
 
A

Alvin Bruney

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.
 
W

William Ryan

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 @.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top