Java Regex Number Validate isNum(String str)

Here you can find the source of isNum(String str)

Description

is Num

License

Apache License

Declaration

public static boolean isNum(String str) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static boolean isNum(String str) {
        if (isBlank(str)) {
            return false;
        }/* ww  w. ja va 2 s .c  o m*/

        String regEx = "[\\d]+";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(str);

        return m.matches();

    }

    public static boolean isBlank(String str) {
        return (str == null || str == "null" || str.trim().length() == 0);
    }
}

Related

  1. isNum(String str)
  2. isNumber(String data)
  3. isNumber(String number)
  4. isNumber(String s)
  5. isNumber(String s)