Perfect: Regular expressions for mobile phone numbers and car grades on the Internet

Source: Internet
Author: User

Now, the mobile phone number and the license plate number are all written before.


Now the phone number has been updated by 177, 147 and so on.


So, the mobile phone number can be perfected a bit:

public static Boolean Checkmobilephone (String mobilephone) {return (Mobilephone==null | | mobilephone.equals ("") | |! Mobilephone.matches ("^ (13) | ( 14) | (15) | (17) | (18)) \\d{9}$ "));}


Moreover, I specifically looked at the car grade of the regular, found that there is a small problem.


public static Boolean checkshopsign (String shopsign) {return (Shopsign==null | | shopsign.equals ("") | |! Shopsign.matches ("^[\u4e00-\u9fa5]{1}[a-z]{1}[a-z_0-9]{5}$"));}

Overall is not much of a problem,just because [\u4e00-\u9fa5] is a match for a Chinese character, so when the Chinese character is not a province abbreviation, but other Chinese characters, it can also be verified by

For example: "I A12345" such a license plate number can also be matched through. Have thought about the solution, but feel that the abbreviation of 34 provinces is very troublesome to match, there is no good way


Just the programmers, when copying the online regular, take care of it.

Perfect: Regular expressions for mobile phone numbers and car grades on the Internet

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.