1. 程式人生 > >java 手機號碼+郵箱的驗證

java 手機號碼+郵箱的驗證

import java.util.regex.Pattern; //匯入的包

 

1:String REGEX_MOBILE = "^((17[0-9])|(14[0-9])|(13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"; // 手機號正則

2:進行匹配
Pattern.matches(REGEX_MOBILE, projectOwner.getContactPhone())

if(Pattern.matches(REGEX_MOBILE, projectOwner.getContactPhone())){

}