问题
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