Write code to check if a string is Positive Integer using regular expression
import java.util.regex.Pattern; public class Main { public static void main(String[] argv) { String s = "123"; System.out.println(isPositiveInteger(s)); }/* ww w. j a va2 s . c o m*/ private static final String POSITIVE_INTEGER_REGEX = "[0-9]+"; private static final Pattern POSITIVE_INTEGER_PATTERN = Pattern.compile(POSITIVE_INTEGER_REGEX); public static final boolean isPositiveInteger(String s) { return POSITIVE_INTEGER_PATTERN.matcher(s).matches(); } }