I have a regex that looks like this
((1010xxx)?(\d{11}|\d{10}|\d{7})+)
Basically I want it to match
8085551234
5551234 10102338085551234and it should fa开发者_如何学Goil on
1010233This is more for validation being done on an xsd than an actual matcher.
PS. I am trying to match US telephone numbers 7 - 11 digits long with an optional 1010xxx at the front. Also if it is 1010xxx it should not pass. xxx is any 3 digits.
If all you want is to make sure that it's a 7, 10, or 11 digit string, making sure that if it's only 7 digits it doesn't start with '1010', you can use a negative lookahead assertion before your match on \d{7}
, i.e.:
((\d{11}|\d{10}|(?!1010)\d{7})+)
精彩评论