Java Regex Number Validate isNumber(String str)

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

Description

is Number

License

Open Source License

Declaration

public static boolean isNumber(String str) 

Method Source Code

//package com.java2s;

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

public class Main {
    private static Pattern numberPattern = Pattern.compile("^\\d+\\.*\\d*$");

    public static boolean isNumber(String str) {
        if (isEmpty(str)) {
            return false;
        }/*from  www.java 2 s .  c  om*/
        Matcher matcher = numberPattern.matcher(str);
        return matcher.matches();

    }

    public static boolean isEmpty(String str) {
        return str == null || str.isEmpty();
    }
}

Related

  1. isNumber(String str)
  2. isNumber(String str)
  3. isNumber(String str)
  4. isNumber(String str)
  5. isNumber(String str)
  6. isNumber(String str)
  7. isNumber(String str, String sign)
  8. isNumber(String value)
  9. isNumber(String value)