We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

URGENT: Easy Regex Question

jjacksn
jjacksn asked
on
Medium Priority
303 Views
Last Modified: 2010-04-15
I'm missing something here,  I only want to allow alphanumeric characters and the period.  i have the following code

Regex regex = new Regex("[^[a-z][A-Z][0-9].]");
if(regex.IsMatch(txtName.Text) == true)

Do I need a carrot before each of those sub groups?  

(the code is not working properly).
Comment
Watch Question

Try this instead, it should do what you want:

Regex regex = new Regex("^[a-zA-Z0-9.]+$");


Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
Regex regex = new Regex("[a-zA-Z0-9.]+");
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.