Click here to Skip to main content
15,898,373 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to validate textbox with regular expression below.

("^(4|5)(?<year>19[5-9][0-9]|[2-9][0-9]{3})(0[1-9]|[1-5][0-9]|6[0-3]{2})[0-9]{6}$");

Where User input starts with either 4 or 5 followed by year from 1950 -9999 followed by 2 digit code and last 6 digits UID.

I am facing issue with 3rd part where it should accept from 01 -63, but it works fine till 59. So I need help with formatting expression to accept 60-63.

Any suggestion and help is appreciated.
Posted
Updated 12-Nov-15 11:05am
v2
Comments
OriginalGriff 12-Nov-15 14:04pm    
When I paste that into Expresso, it says (rightly) "Illegal group syntax" in the second group. There is no regex group that starts "(?" immediately followed by a digit.
Member 12076824 12-Nov-15 17:08pm    
("^(4|5)(?<year>19[5-9][0-9]|[2-9][0-9]{3})(0[1-9]|[1-5][0-9]|6[0-3]{2})[0-9]{6}$");

Thanks for response, for some reason in question <year> is missing.
Maciej Los 12-Nov-15 14:56pm    
What is exact input which match your criteria?
Member 12076824 12-Nov-15 17:07pm    
Thanks for response I am trying something like 4201563000001

In the group
(0[1-9]|[1-5][0-9]|6[0-3]{2})

Remove the {2}
 
Share this answer
 
Comments
Member 12076824 12-Nov-15 17:10pm    
Thanks Matt, it's working fine.
Maciej Los 13-Nov-15 1:55am    
5ed!
This site may help you to understand your regex.
https://www.debuggex.com/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900