The regular expression verifies the QQ number and the regular expression number.

Source: Internet
Author: User

The regular expression verifies the QQ number and the regular expression number.

If you don't talk much about it, paste the Code directly. The specific code is as follows:

Package regular expression;/* verification requirements for QQ numbers 5 ~ 15 digits. It cannot start with 0 and can only be numbers */import java. util. regex. matcher; import java. util. regex. pattern; public class Test {public static void main (String [] args) {// TODO Auto-generated method stub String qq = "23412312 "; string regex = "[1-9] [0-9] {4, 14}"; // a number between the first digit and the second digit, the number range is 4-14. // String regex2 = "[1-9] \ d {4, 14}"; // This sentence can also be boolean flag = qq. matches (regex); if (flag) System. out. println ("correct QQ number"); else System. out. println ("Incorrect QQ number ");}}

The above is the regular expression introduced by the editor to verify the QQ number. I hope it will be helpful to you. If you have any questions, please leave a message and the editor will reply to you in time. Thank you very much for your support for the help House website!

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.