Android authentication phone number, user name regular expression

Source: Internet
Author: User

Verifying the phone number regular expression

Now the number is too much, everything has, then relax the requirements of the Bai

A combination of 11-digit numbers starting with 1

    /**     * Verify mobile phone number     * @param phonenumber Mobile Number     * @return Boolean *     /Public    static Boolean Checkphonenumber ( String phonenumber) {        Pattern pattern=pattern.compile ("^1[0-9]{10}$");        Matcher Matcher=pattern.matcher (phonenumber);        return matcher.matches ();    }

Verify user names, such as 6-to 12-digit alphanumeric combinations

    /**     * Verify user name     * @param username username     * @return Boolean *    /public static Boolean Checkusername ( String username) {        string regex = "([a-za-z0-9]{6,12})";        Pattern p = pattern.compile (regex);        Matcher m = p.matcher (username);        return m.matches ();    }


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android authentication phone number, user name regular expression

Related Article

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.