Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static boolean match(String str, String rex) { if (null == str || str.trim().length() == 0) { return false; } Pattern pattern = Pattern.compile(rex); Matcher isNum = pattern.matcher(str); return isNum.matches(); } }