Click here to Skip to main content
15,897,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
^(230|231)\d{6}$|^(01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38)\d{7}$

In the above regex i want to exclude the 18 and 19 how can i do so
Posted

1 solution

Simple: don't use a regex.
Regexs are for pattern matching in strings - you can already see that your regex is getting nasty and difficult to work with. Do string matching in the regex, then use code to convert matched numbers and check them there.

Regexes are wonderful tools - but only when they are used on appropriate tasks.

If you must use a regex, then just take out the "18|19|" part of the match string. But seriously, I'd use code here.
 
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