Java examples for java.util.regex:Match Number
is Integer by regex
//package com.java2s; import java.util.regex.*; public class Main { public static void main(String[] argv) throws Exception { String str = "java2s.com"; System.out.println(isInteger(str)); }// ww w . j a v a2 s . co m public static boolean isInteger(String str) { Pattern pattern = Pattern.compile("^[\\d]*$"); return pattern.matcher(str).matches(); } }