【转】关于金额验证的Java方法(采用正则表达式)

public static boolean isNumber(String str) {  
        java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("[0-9]*");  
        java.util.regex.Matcher match = pattern.matcher(str.trim());  
        return match.matches();  
    }  
  
    public static boolean isBigDecimal(String str) {  
        java.util.regex.Matcher match =null;  
        if(isNumber(str)==true){  
            java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("[0-9]*");  
            match = pattern.matcher(str.trim());  
        }else{  
            if(str.trim().indexOf(".")==-1){  
                java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("^[+-]?[0-9]*");  
                match = pattern.matcher(str.trim());  
            }else{  
                java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("^[+-]?[0-9]+(\\.\\d{1,100}){1}quot;);  
                match = pattern.matcher(str.trim());                  
            }  
        }  
        return match.matches();  
    }

 

你可能感兴趣的:(正则表达式)