java常用简单正则表达式写法

邮箱的判断

1  /**
2      * 判断email是否合法
3      */
4     public static boolean checkLoginEmail(String loginStr) {
5         String regEx = "^([a-z0-9_A-Z]+[-|\\.]?)+[a-z0-9_A-Z]@([a-z0-9_A-Z]+(-[a-z0-9_A-Z]+)?\\.)+[a-zA-Z_]{2,}$";
6         Pattern p = Pattern.compile(regEx);
7         Matcher m = p.matcher(loginStr);
8         return m.matches();// boolean
9     }

简单格式

public static boolean isKaChao(String kachao){  
        Pattern p = Pattern.compile("^(0){5}3[0-9]{4}$");  
        Matcher m = p.matcher(kachao); 
        return m.matches();
        }

 

posted @ 2015-05-29 11:04  F_YuXiang  阅读(3289)  评论(0编辑  收藏  举报