PackageCom.ict.modules.plateform.tool;ImportJava.util.regex.Matcher;ImportJava.util.regex.Pattern;Importorg.apache.commons.lang3.StringUtils;/*** Regular Expression tool class *@authorHSW **/ Public classRegularutil {/*** Check the phone number * True=ismobile ("18910808534") * False=ismobile ("28910808534") * False=ismobile ("") * FAL Se=ismobile (NULL) *@paramMobilenum *@return */ Public Static Booleanismobile (String mobilenum) {Booleanb =false; if(Stringutils.isblank (mobilenum))returnb; Pattern P=NULL; Matcher m=NULL; P= Pattern.compile ("^[1][3,4,5,7,8][0-9]{9}$");//Verify your phone numberm =P.matcher (Mobilenum); b=m.matches (); returnb; } /*** Check Email *@paramEmail *@return */ Public Static Booleanisemail (String email) {Booleanb =false; if(Stringutils.isblank (email))returnb; Pattern P=NULL; Matcher m=NULL; P= Pattern.compile ("^ ([a-z0-9a-z]+[-|\\.]?) +[a-z0-9a-z]@ ([a-z0-9a-z]+ (-[a-z0-9a-z]+) \ \.) +[a-za-z]{2,}$ ");//Verify Mailboxm =p.matcher (email); b=m.matches (); returnb; }}
Java Regular expression mobile phone number e-mail