all groups > asp.net > may 2005 >
You're in the

asp.net

group:

regular expression



Re: regular expression Karl Seguin
5/31/2005 4:17:48 PM
asp.net: Try:
^[1-9](\d[1-9]|[1-9])?$

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
[quoted text, click to view]

regular expression JB
5/31/2005 9:45:30 PM
Please can anybody help me with this.

I have a form that reads the numbers of team members. The numbers logic
is that it is 1 to 3 digits long. The first and the last digit can not be 0.

I don't get a regelar expression to work.

Examples
0 does not match
1 matches (as do the digits 1 to 9)
12 matches
01 or 10 don't match.
101 matches
001 does not match
110 does not match.

I tried combination of
[0-9]{1,3} with ^[1-9] and [1-9]$
It looks like I need a logical AND

Input is 3 digits AND the first digit is not 0 AND the last digit is not 0.

Any help is appreciated,

AddThis Social Bookmark Button