ayha1999
asked on
Regular expression
Hi,
How can validate the following format?
00 to 90 (00,10,20,30,40,50,60,70,8 0,90 only)-
00 to 99-
00 to 20
ayha
How can validate the following format?
00 to 90 (00,10,20,30,40,50,60,70,8
00 to 99-
00 to 20
ayha
ASKER
Hi,
the folliwng line accepts 1 without 0. can u modify it to accept only two digits like 01,02 ... 20?
thanks
ayha
the folliwng line accepts 1 without 0. can u modify it to accept only two digits like 01,02 ... 20?
thanks
ayha
The following revision:
^(0[0-9])$|^(1[0-9])$|^(20 )$
Will only accept 2-digit numbers from 00 to 20.
Broken down as:
First Character 0 with a second character between 0 to 9,
OR
First character 1 with a second character between 0 to 9
OR
the number 20.
Paul
^(0[0-9])$|^(1[0-9])$|^(20
Will only accept 2-digit numbers from 00 to 20.
Broken down as:
First Character 0 with a second character between 0 to 9,
OR
First character 1 with a second character between 0 to 9
OR
the number 20.
Paul
You can also write the above as:
^(0[0-9])|(1[0-9])|(20)$
Paul
^(0[0-9])|(1[0-9])|(20)$
Paul
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For 00 - 99 use ^([0-9][0-9])$
For 00 - 20 use ^([0-9]|[1][0-9]|20)$
Paul