1. Email Verification:
PackagejavaRegx2016311;ImportJava.util.regex.Matcher;ImportJava.util.regex.Pattern; Public classJAVAREGX {/*** Summary of Use of Java regular Expressions*/ /*** Verify that the format of the mailbox is correct *@paramEmailstr *@return */ Public Static BooleanCheckemail (FinalString Emailstr) { //Regular Expressions for mailboxesString regEx = "[a-za-z_]{1,}[0-9]{0,}@ ([a-za-z0-9]-*] {1,}\\.) {1,3} [a-za-z\\-] {1,} "; //Compiling regular ExpressionsPattern pattern =Pattern.compile (regEx); //Ignore case-written notationPattern pattern2 =pattern.compile (regEx, pattern.case_insensitive); Matcher Matcher=Pattern.matcher (EMAILSTR); //whether character creation matches regular expressions Booleanresult =matcher.matches (); returnresult; } }
PackagejavaRegx2016311;ImportJava.util.regex.Matcher;ImportJava.util.regex.Pattern; Public classJAVAREGX {/*** Summary of Use of Java regular Expressions*/ /*** Verify that the format of the mailbox is correct *@paramEmailstr *@return */ Public Static BooleanCheckemail (FinalString Emailstr) { //Regular Expressions for mailboxesString regEx = "[a-za-z_]{1,}[0-9]{0,}@ ([a-za-z0-9]-*] {1,}\\.) {1,3} [a-za-z\\-] {1,} "; //Compiling regular ExpressionsPattern pattern =Pattern.compile (regEx); //Ignore case-written notationPattern pattern2 =pattern.compile (regEx, pattern.case_insensitive); Matcher Matcher=Pattern.matcher (EMAILSTR); //whether character creation matches regular expressions Booleanresult =matcher.matches (); returnresult; } /*** Query Whether a string is not a word Shi string or character *@paramcheckstr Total String *@paramCheckingstr string to be validated *@return */ Public Static BooleanCHECKSTR (FinalString Checkstr,FinalString Checkingstr) { //Regular ExpressionsString regEx = checkingstr+ ". *"; //Compiling regular ExpressionsPattern pattern =Pattern.compile (regEx); //Ignore case-written notationPattern pattern2 =pattern.compile (regEx, pattern.case_insensitive); Matcher Matcher=Pattern.matcher (CHECKSTR); Booleanresult =Matcher.find (); //returns a Bollean value that determines whether the character or string is included returnresult; } /*** Verify that there are no kanji in a string *@paramCheckword *@return */ Public Static BooleanCheckchinaword (FinalString Checkword) { //Verify that there are regular expressions with Chinese charactersString regEx = "^[\u0391-\uffe5]+$"; //Compiling regular ExpressionsPattern pattern =Pattern.compile (regEx); Matcher Matcher=Pattern.matcher (Checkword); //Returns a Boolean expression that is not a Chinese character Booleanresult =matcher.matches (); //Returns the result: Returns True if the string has kanji, otherwise returns alse returnresult; } }
Java code Collation---regular expressions