Easy RegEx question

A

Alan Silver

Hello,

Suppose I have a string and I want to strip out all characters that are
not plain letters or digits. How do I do this? I'm sure it's a pretty
simple regex, but I'm not very good at them ;-(

TIA
 
J

jeff_carver

VB.NET example:

Dim strOld As String = "?Nowhere^Man&123%"
Dim strNew = Regex.Replace(strOld, "[^0-9a-zA-Z]", "")

strNew should now = "NowhereMan123"
 
A

Alan Silver

VB.NET example:
Dim strOld As String = "?Nowhere^Man&123%"
Dim strNew = Regex.Replace(strOld, "[^0-9a-zA-Z]", "")

strNew should now = "NowhereMan123"

Thanks, that was exactly what I wanted!!
 
A

Alan Silver

Check this out!

Thanks, that's a great resource. Pity they don't have a better way to
browse the contents. I found the searching very hit and miss. It would
have been nice if they had put the regexs into categories for easy
browsing.

Still, worth knowing about. Thanks again.
 

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

Similar Threads

RegEx 0
Regex replace problem 2
Question 0
My regex kung-fu is not strong =( 0
Question 1
Regex Question 2
regex question 7
Very simple regex question 2

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top