User input telephone number, judge reasonable or not? requirements, judging length and judging whether the input content is reasonable hide the middle 4 digits of the user's phone number

Source: Internet
Author: User

/** * User Input phone number, judge whether reasonable or not? Ask, judge the length and judge the input is reasonable * Hide the user phone number in the middle of 4, * ideas: * *. With regular judgment conditions: Length 11-bit judgment there are two methods, regular {11} and Length () ==11. Input content with regular judgment * telephone number of the regular: "() [0-9][\\d]{8}| (15) [0-9] [\\d] {8} "*/
 Public class StringDemo4 {    publicstaticvoid  main (string[] args) {        = " 15942081304 ";         = "() [0-9][\\d]{8}| (15) [0-9] [\\d] {8} ";        System.out.println (Inttelnum.matches (Telregex));         = inttelnum.substring (3,7);        System.out.println (covernum);         = Inttelnum.replace (Covernum, "* * * *");        System.out.println (Inttelnum);    }}
View Code

User input telephone number, judge reasonable or not? requirements, judging length and judging whether the input content is reasonable hide the middle 4 digits of the user's phone number

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.