Android examples for java.util.regex:Numeric Pattern
match Integer by regex
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final String V_INTEGER = "^-?[1-9]\\d*$"; public static boolean Integer(String value) { return match(V_INTEGER, value); }// www .j a va2 s. c om private static boolean match(String regex, String str) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str); return matcher.matches(); } }