Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
^(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 20-Feb-13 19:46pm
lalitkr1.5K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100