Re: Regex Help
- From: Göran Andersson <guffa@xxxxxxxxx>
- Date: Thu, 01 Mar 2007 17:50:38 +0100
Alexey Smirnov wrote:
On Mar 1, 4:29 pm, "G" <g...@xxxxxxxxxx> wrote:Hello,
I have a REGEX validator which checks for DIGITS ONLY, 10 or 11 digits in
length. The pattern is:#
^\d{10,11}$
I would like to enhance this pattern so in addition to only digits, and
string must be 10 or 11 characters in length, - I would like the first
character to be a 0, and the second character must NEVER be a 0.
Matches:
0100000000
01234567890
0101010101
Non Matches:
1000000000
0010000000
1010101010
Any regex pro's here able to assist?
Kind Regards,
Gary.
^0(?!0)\d{8,9}$
That would be:
^0(?!0)\d{9,10}$
as the look-ahead doesn't consume the character. :)
Here's another way of writing it, perhaps a bit more straight forward:
^0[1-9]\d{8,9}$
--
Göran Andersson
_____
http://www.guffa.com
.
- References:
- Re: Regex Help
- From: Alexey Smirnov
- Re: Regex Help
- Prev by Date: Dynamically set a control property
- Next by Date: Re: Is this a legitimate web site or a 'phish'?
- Previous by thread: Re: Regex Help
- Next by thread: Visual Studio 2005 SP1 warning
- Index(es):
Relevant Pages
|