is English Number By Regex - Java java.util.regex

Java examples for java.util.regex:Match Number

Description

is English Number By Regex

Demo Code


//package com.java2s;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static final String STR_ENG_NUM_ = "^\\w+$";

    public static boolean isENG_NUM_(String str) {
        return Regular(str, STR_ENG_NUM_);
    }/*from   w  w w  .  ja  v a  2s. c o m*/

    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();
    }
}

Related Tutorials