阅读背景:

java正则验证数字、邮箱格式、字符串

来源:互联网 


用java代码正则验证数字、邮箱格局、字符串的一些工具类办法

        // 断定数字  
        public static boolean isNumberic(String s) {  
            return Pattern.compile("([1-9]+|0)\.*[0-9]+").matcher(s).matches();  
        }  
      
        // 断定邮箱  
        public static boolean isEmail(String s) {  
            return Pattern.compile("\w+@{1}\w+\.{1}\w+").matcher(s).matches();  
        }  
      
        // 包括某个字符  
        public static boolean contains(String s, String c) {  
            return Pattern.compile(".*" + c + "+.*").matcher(s).matches();  
        }  
      
        // 以某个字符串开头  
        public static boolean startWith(String s, String c) {  
            return Pattern.compile("^" + c + "\w*").matcher(s).matches();  
        }  
      
        // 以某个字符串结尾  
        public static boolean endWith(String s, String c) {  
            return Pattern.compile("\w*" + c + "$").matcher(s).matches();  
        }  

        // 断定数字  




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: