Forum Moderators: coopster

Message Too Old, No Replies

Regex: preg match() Help

I need to accept only 14 digits number

         

a naguib 2000

3:23 pm on Jun 7, 2009 (gmt 0)

10+ Year Member



Hello,
How can I accept only 14 digits number with the leftmost digit not equal to zero (i.e from 10000000000000 to 99999999999999)?

My best trial was lacking condition of that the first number must not equal to zero:
preg_match("/\A\d{14}\z/",$no)

thanks

Nutter

3:39 pm on Jun 7, 2009 (gmt 0)

10+ Year Member



/[1-9]{1}\d{13}/ should do it.

a naguib 2000

3:41 pm on Jun 8, 2009 (gmt 0)

10+ Year Member



Thanks a lot Nutter.. Works perfectly..