Android Express Tool Class

Source: Internet
Author: User

1  Packagecom.example.administrator.magiclamp.utils;2 3 ImportJava.util.regex.Pattern;4 5 /**6 * Validator: Use regular expression to check the mailbox, mobile phone number, etc.7  * @authorMr.duan8  */9  Public classValidator {Ten     /** One * Regular expression: Verify user name (not including Chinese and special characters) combined with phone number verification and mailbox verification if user name uses mobile phone number or mailbox A      */ -      Public Static FinalString regex_username = "^[a-za-z]\\w{5,17}$"; -   the     /** - * Regular expression: Verify password (does not contain special characters) -      */ -      Public Static FinalString Regex_password = "^[a-za-z0-9]{1,12}$"; +   -     /** + * Regular expression: Verify the phone number A      */ at      Public Static FinalString regex_mobile = "^ ((13[0-9]) | ( 15[^4,\\D]) | (18[0,5-9])) \\d{8}$ "; -   -     /** - * Regular expression: Verify mailbox -      */ -      Public Static FinalString Regex_email = "^ ([a-z0-9a-z]+[-|\\.]?) +[a-z0-9a-z]@ ([a-z0-9a-z]+ (-[a-z0-9a-z]+) \ \.) +[a-za-z]{2,}$ "; in   -     /** to * Regular expression: Validate kanji (1-9 kanji) {1,9} custom interval +      */ -      Public Static FinalString Regex_chinese = "^[\u4e00-\u9fa5]{1,9}$"; the   *     /** $ * Regular expression: Verify IDPanax Notoginseng      */ -      Public Static FinalString Regex_id_card = "(\\d{14}[0-9a-za-z]) | (\\d{17}[0-9a-za-z]) "; the   +     /** A * Regular expression: Verify URL the      */ +      Public Static FinalString Regex_url = "http (s)?:/ /([\\w-]+\\.) +[\\w-]+ (/[\\w-./?%&=]*)? "; -   $     /** $ * Regular expression: Verify IP address -      */ -      Public Static FinalString regex_ip_addr = "(2[5][0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2}) \ \. (25[0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2}) \ \. (25[0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2}) \ \. (25[0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2}) "; the   -     /**Wuyi * Verify user name the      *  -      * @paramusername Wu      * @returnThe checksum returns TRUE, otherwise false -      */ About      Public Static BooleanIsusername (String username) { $         returnpattern.matches (Regex_username, USERNAME); -     } -   -     /** A * Check Password +      *  the      * @paramPassword -      * @returnThe checksum returns TRUE, otherwise false $      */ the      Public Static BooleanIspassword (String password) { the         returnpattern.matches (Regex_password, PASSWORD); the     } the   -     /** in * Check the phone number the      *  the      * @paramMobile About      * @returnThe checksum returns TRUE, otherwise false the      */ the      Public Static BooleanIsMobile (String mobile) { the         returnpattern.matches (Regex_mobile, MOBILE); +     } -   the     /**Bayi * Check Mailbox the      *  the      * @paramEmail -      * @returnThe checksum returns TRUE, otherwise false -      */ the      Public Static Booleanisemail (String email) { the         returnpattern.matches (Regex_email, EMAIL); the     } the   -     /** the * Check Kanji the      *  the      * @paramChinese94      * @returnThe checksum returns TRUE, otherwise false the      */ the      Public Static BooleanIschinese (String Chinese) { the         returnpattern.matches (Regex_chinese, Chinese);98     } About   -     /**101 * Verify ID102      * 103      * @paramIdcard104      * @returnThe checksum returns TRUE, otherwise false the      */106      Public Static BooleanIsidcard (String idcard) {107         returnpattern.matches (Regex_id_card, idcard);108     }109   the     /**111 * Check URL the      * 113      * @paramURL the      * @returnThe checksum returns TRUE, otherwise false the      */ the      Public Static Booleanisurl (String url) {117         returnpattern.matches (Regex_url, URL);118     }119   -     /**121 * Verify IP address122      * 123      * @paramipAddress124      * @return the      */126      Public Static Booleanisipaddress (String ipAddress) {127         returnpattern.matches (regex_ip_addr, ipAddress); -     }129     the}

Android Express Tool Class

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.