/** * 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