问题
Possible Duplicate:
A comprehensive regex for phone number validation
Greetings,
I need to implement a jquery based validation for a text field that contains a phone number, for that I need the regular expression of these two strings, I am requesting this because I am very naive with RegEx:
First One:
0(5NN) NNN NN NN
Second One:
0(53N) NNN NN NN
N means an integer between 0-9
回答1:
^0\(5\d{2}\) ?\d{3} ?\d{2} ?\d{2}$
and
^0\(53\d\) ?\d{3} ?\d{2} ?\d{2}$
will match. You can drop the ? if you are sure that there will always be space characters in the places you wrote them.
回答2:
This will match either one:
^0\(5\d\d\) \d\d\d \d\d \d\d$
回答3:
Why is the first not a superset of the second? Are we sure the (5NN) in the first is the full set of integers (5[0-9][0-9]), or is the 3 in the second combination (53[0-9]) significant in some way to exclude certain parts of [0-9]?
来源:https://stackoverflow.com/questions/2541058/a-specific-phone-number-regex