| 
 
| package day01; 
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 public class 练习正则表达式 {
 
 public static void main(String[] args) {
 // TODO Auto-generated method stub
 String emailreg = "^([a-z0-9A-Z]+@[a-z0-9A-Z]+(\\.com|\\.cn|\\.net))$";
 String phonereg = "^((180)|(139)|(15[^4,\\D])\\d{8})$";
 String emailformat = "2015272261@qq.com";
 String phoneformat = "15527667442";
 Pattern patternphone = Pattern.compile(phonereg);
 Pattern patternemil = Pattern.compile(emailreg);
 Matcher matcheremil = patternemil.matcher(emailformat);
 Matcher matcherphone = patternphone.matcher(phoneformat);
 if(matcherphone.find()&&matcheremil.find()){
 System.out.println("手机号码和邮箱号验证通过");
 }else{
 System.out.println("手机号码和邮箱号不通过");
 }
 }
 
 }
 
 | 
 |