Determine if the phone number and phone number
package com.rk.utils;import java.util.regex.matcher;import java.util.regex.pattern;public class regexutils{/** * Mobile phone number verification * * @param str * @return Verify by returning True */public static boolean ismobile (STRING STR) {pattern p = Null Matcher m = null;boolean b = false;p = pattern.compile ("^[1][3,4,5,8][ 0-9]{9}$ "); // Verify the phone number m = p.matcher (str); b = m.matches (); return b;} /** * phone number verification * * @param str * @return verification by returning true */ Public static boolean isphone (string str) {pattern p1 = null, p2 = null; Matcher m = null;boolean b = false;p1 = pattern.compile ("^[0][1-9]{2,3 }-[0-9]{5,10}$ "); // verify P2 = pattern.compile with area code (" ^[1-9]{1}[0-9]{5,8}$ "); // Verify that no area code is IF&NBSp; (Str.length () > 9) {m = p1.matcher (str); b = m.matches ();} Else{m = p2.matcher (str); b = m.matches ();} Return b;}}
Java Tools class: (1) Determine if string is a mobile number