validating the mobile numbers

≯℡__Kan透↙ 提交于 2020-01-15 09:32:06

问题


I need a regular expression to validate the mobile number up to 9 digits, if the telephone number starts with 8 otherwise 10 digits needs to be entered. The numbers must start either with 9 or 8 with above criteria.


回答1:


^(8\d{8}|[1-79]\d{9})$



回答2:


Not sure about the answer, but you should check out this very useful website for reg expressions incase you are interested:

http://www.regexlib.com

http://www.regexlib.com/CheatSheet.aspx




回答3:


Use the following regular expression to match the phone numbers starting with 8 or 9.

^8|9(8\d{8}|[1-79]\d{9})$


来源:https://stackoverflow.com/questions/2947462/validating-the-mobile-numbers

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