Java code Collation---regular expressions

Source: Internet
Author: User

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

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.