Regular expression validation


I am working on web application VS2003 using C#

I wish to do validate a field in a form using regular expression

The text in the field should be of minimum length 6 and maximum 15 and all should be numeric and must contain dot(.)

and another valiadtion to validate textfield with alphanumeric, there only alphabets and numeric should exists, user should not be able to put any special characters other then space and -

Please guide in writting regular expression

Who is Participating?
ozoConnect With a Mentor Commented:
If you require 2 dots, that could be
for a minimum of 3 dots

^[- A-Za-z0-9]*$
* is like {0,infinity}

^[- A-Za-z0-9]{6,15}$
tia_kamakshiAuthor Commented:
Thanks for your reply.

This seems good but I have little problem and need your guidence

1. ^(?=.*[.])[.0-9]{6,15}$

--> How did you manage to get that there should be atleast 2 dots in this. If I have to validate that there should be atleast one dot other than 2 dots, then where I should change it

--> Also, If I have to Increase that there should be atleast 3 dots than how this expression will be changed

2. ^[- A-Za-z0-9]{6,15}$

--> Here I do not wanted the minimum and maximum length , I removed {6,15} from expression then it stopped working

Please guide
tia_kamakshiAuthor Commented:
Thanks, I will test and come back to you.
tia_kamakshiAuthor Commented:
All Courses

From novice to tech pro — start learning today.