A specific Phone Number RegEX [duplicate]

若如初见. 提交于 2019-12-12 05:13:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!