Java examples for java.util.regex:Match Number
is Integer Positive by Regex
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static final String INTEGER_POSITIVE = "^[1-9]\\d*$"; public static boolean isINTEGER_POSITIVE(String str) { return Regular(str, INTEGER_POSITIVE); }/*from w w w. ja va 2 s . com*/ private static boolean Regular(String str, String pattern) { if (null == str || str.trim().length() <= 0) return false; Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(str); return m.matches(); } }