東西不多,但一般項(xiàng)目夠用了。
成都創(chuàng)新互聯(lián)公司主營(yíng)阿魯科爾沁網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,app軟件開(kāi)發(fā)公司,阿魯科爾沁h(yuǎn)5小程序設(shè)計(jì)搭建,阿魯科爾沁網(wǎng)站營(yíng)銷(xiāo)推廣歡迎阿魯科爾沁等地區(qū)企業(yè)咨詢
public class RegularUtil { //身份證 public static final String REGEX_ID_CARD = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9]|X)$"; //驗(yàn)證郵箱 public static final String REGEX_EMAIL = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; //手機(jī)號(hào) public static final String REGEX_PHONE = "0?(13|14|15|17|18)[0-9]{9}"; //漢字 public static final String REGEX_TRUENAME = "^[\\u4e00-\\u9fa5]*$"; //銀行卡 public static final String BANKNUMBER="^([0-9]{16}|[0-9]{19})$"; //固話電話正則 public static final String TELE= "([0-9]{3,4}-)?[0-9]{7,8}"; //密碼強(qiáng)度驗(yàn)證 public static final String REGEX_PWS="^(((?=.*[0-9])(?=.*[a-zA-Z])|(?=.*[0-9])(?=.*[^\\s0-9a-zA-Z])|(?=.*[a-zA-Z])(?=.*[^\\s0-9a-zA-Z]))[^\\s]+)$"; public static boolean isPhone(String mobiles){ if (TextUtils.isEmpty(mobiles)){ return false; }else{ return mobiles.matches(REGEX_PHONE); } } public static boolean isTel(String mobiles) { if (TextUtils.isEmpty(mobiles)) { return false; } else { return mobiles.matches(TELE); } } public static boolean isIDacard(String idcard){ if (TextUtils.isEmpty(idcard)) return false; else return idcard.matches(REGEX_ID_CARD); } public static boolean isBankCard(String bankcard){ if (TextUtils.isEmpty(bankcard)) return false; else return bankcard.matches(BANKNUMBER); } public static boolean isEmail(String email){ if (TextUtils.isEmpty(email)) return false; else return email.matches(REGEX_EMAIL); } public static boolean isTrueName(String name){ if (TextUtils.isEmpty(name)) return false; else return name.matches(REGEX_TRUENAME); } //驗(yàn)證密碼強(qiáng)度 public static boolean isPsw(String psw) { //包含數(shù)字,字母,特殊符號(hào)其中至少兩種 if (TextUtils.isEmpty(psw)) { return false; } else { //限制長(zhǎng)度 if(psw.length()<6||psw.length()>16){ return false; } //matches():字符串是否在給定的正則表達(dá)式匹配 return psw.matches(REGEX_PWS); } } }
總結(jié)
以上所述是小編給大家介紹的Android常用正則表達(dá)式驗(yàn)證工具類(實(shí)例代碼),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)創(chuàng)新互聯(lián)網(wǎng)站的支持!
當(dāng)前題目:Android常用正則表達(dá)式驗(yàn)證工具類(實(shí)例代碼)
網(wǎng)站地址:http://aaarwkj.com/article40/ijhpho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、全網(wǎng)營(yíng)銷(xiāo)推廣、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、用戶體驗(yàn)、App設(shè)計(jì)、靜態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)