Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: regularexpressionvalidator-leading zero


Message #1 by "John Tyson" <jtyson@t...> on Mon, 17 Mar 2003 12:58:59 -0800
Hi,

I am not very familiar with writing regular expressions.  What I am
trying to do is limit textbox input to two digits, numeric, and if the
entry is less than 10 that it requires a leading zero.

Can someone please help me with this?  Links to regular expression
sources and repositories are also appreciated.

Thank you.

John
Message #2 by "Jonathan Larouche" <jlarouche@d...> on Tue, 18 Mar 2003 17:08:54
Hi,
Use this regular expression : "^\d\d$"
where:
^  = begin of string
\d = any digit number 0 to 9
$  = end of string

This will match when string = "01" "03" "20" "99"...
and will not match when string = "1" "123" "2.3"...


Thanks
Jonathan
jlarouche@d...

many regular expression could be found @ http://regxlib.com/

> Hi,

I am not very familiar with writing regular expressions.  What I am
trying to do is limit textbox input to two digits, numeric, and if the
entry is less than 10 that it requires a leading zero.

Can someone please help me with this?  Links to regular expression
sources and repositories are also appreciated.

Thank you.

John
Message #3 by "John Tyson" <jtyson@t...> on Tue, 18 Mar 2003 09:44:45 -0800
Hi Jonathan,

Thank you for responding.  How does the expression below know the entry
should be two characters in length?

Thank you,

John

-----Original Message-----
From: Jonathan Larouche [mailto:jlarouche@d...]
Sent: Tuesday, March 18, 2003 9:09 AM
To: ASP.NET
Subject: [aspx] Re: regularexpressionvalidator-leading zero

Hi,
Use this regular expression : "^\d\d$"
where:
^  =3D begin of string
\d =3D any digit number 0 to 9
$  =3D end of string

This will match when string =3D "01" "03" "20" "99"...
and will not match when string =3D "1" "123" "2.3"...


Thanks
Jonathan
jlarouche@d...

many regular expression could be found @ http://regxlib.com/

> Hi,

I am not very familiar with writing regular expressions.  What I am
trying to do is limit textbox input to two digits, numeric, and if the
entry is less than 10 that it requires a leading zero.

Can someone please help me with this?  Links to regular expression
sources and repositories are also appreciated.

Thank you.

John
Message #4 by "Jonathan Larouche" <jlarouche@d...> on Wed, 19 Mar 2003 13:19:09
"^\d\d$" mean Start + Digit + Digit + End : Reapeat the \d 2 times

You can also use this expression "^[\d]{2}$" that mean Start + Digit*2 + 
End

If you would like to permit one or two digit use this expression:
"^[\d]{1,2}$", {n1,n2} = n1 = min repeating times and n2 max reapeating 
times

Hope this will help you

Thanks

Jonathan

> Hi Jonathan,

Thank you for responding.  How does the expression below know the entry
should be two characters in length?

Thank you,

John

-----Original Message-----
From: Jonathan Larouche [mailto:jlarouche@d...]
Sent: Tuesday, March 18, 2003 9:09 AM
To: ASP.NET
Subject: [aspx] Re: regularexpressionvalidator-leading zero

Hi,
Use this regular expression : "^\d\d$"
where:
^  =3D begin of string
\d =3D any digit number 0 to 9
$  =3D end of string

This will match when string =3D "01" "03" "20" "99"...
and will not match when string =3D "1" "123" "2.3"...


Thanks
Jonathan
jlarouche@d...

many regular expression could be found @ http://regxlib.com/


  Return to Index