1jaws
asked on
regex question
parsing "(19|20)\d\d/[1-9]|1[012]) /([1-9]|[1 2][0-9]|3[ 01]" - Too many )'s.
I am trying to do date of birth textbox validate to see if they enter correct date.. it is
yyyy/mm/dd format ...getting this error above..
I am trying to do date of birth textbox validate to see if they enter correct date.. it is
yyyy/mm/dd format ...getting this error above..
where is the ( that matches the ) after 1[012]?
perhaps you meant
"(19|20)\d\d/([1-9]|1[012] )/([1-9]|[ 12][0-9]|3 [01])"
"(19|20)\d\d/([1-9]|1[012]
ASKER
ok it fixed the error but what I am trying to accomplish is not.. I have for ex 1948/01/07 it is saying not correct format... can you please help on the regex how to do tha...
Your regex is only accepting that date in the form 1948/1/7
Do you want the leading 0 to be optional or required?
Do you want the leading 0 to be optional or required?
ASKER
since I want that in yyyy/mm/dd it should be required...or I guess we can make optional so user wont have to figure it out.. what do youthink?
ASKER
can we also add year 2000 to it is only accepting 19.. numbers now..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
remove the ? to make the 0 required
ASKER
can we also add year 2000 to it is only accepting 19.. numbers now..
(19|20) should accept either 19.. or 20..
You may want to rearrange the day part of the expression as follows:
(19|20)\d\d/(0?[1-9]|1[012 ])/(3[01]| [12][0-9]| 0?[1-9])
The pattern above seems to match only "1948/5/1" when the test string is "1948/5/12".
(19|20)\d\d/(0?[1-9]|1[012
The pattern above seems to match only "1948/5/1" when the test string is "1948/5/12".
>>>> parsing "(19|20)\d\d/[1-9]|1[012]) /([1-9]|[1 2][0-9]|3[ 01]" - Too many )'s.
do like this:
((19|20)\d\d)/([1-9]|1[012])/([1-9]|[12][0-9]|3[01])
You had extra ')' 's in your expression so you were getting parsing error.
do like this:
((19|20)\d\d)/([1-9]|1[012])/([1-9]|[12][0-9]|3[01])
You had extra ')' 's in your expression so you were getting parsing error.
ASKER
thanks sorry for the delayed response!!