Link to home
Start Free TrialLog in
Avatar of jjacksn
jjacksn

asked on

URGENT: Easy Regex Question

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).
Avatar of eric_duncan
eric_duncan

Try this instead, it should do what you want:

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


ASKER CERTIFIED SOLUTION
Avatar of eric_duncan
eric_duncan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Regex regex = new Regex("[a-zA-Z0-9.]+");