Regular expression validation

Hi,

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

Thanks
tia_kamakshiAsked:
Who is Participating?
 
ozoConnect With a Mentor Commented:
If you require 2 dots, that could be
^(?=.*[.].*[.])[.0-9]{6,15}$
for a minimum of 3 dots
^(?=.*[.].*[.].*[.])[.0-9]{6,15}$
or
^(?=(.*[.]){3})[.0-9]{6,15}$

^[- A-Za-z0-9]*$
* is like {0,infinity}
0
 
ozoCommented:
^(?=.*[.])[.0-9]{6,15}$

^[- A-Za-z0-9]{6,15}$
0
 
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
0
 
tia_kamakshiAuthor Commented:
Thanks, I will test and come back to you.
0
 
tia_kamakshiAuthor Commented:
Thanks
0
All Courses

From novice to tech pro — start learning today.