Java Regex Number Validate isNumber(String str)

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

Description

is Number

License

Apache License

Declaration

public static boolean isNumber(String str) 

Method Source Code

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

import java.util.regex.Pattern;

public class Main {
    public static boolean isNumber(String str) {
        if (str == null) {
            return true;
        }// ww w. ja va2 s . c  om
        // Pattern pattern = Pattern.compile("[0-9]*");
        String regExp = "^(-|\\+)?\\d+(\\.\\d+)?$";
        Pattern pattern = Pattern.compile(regExp);
        return pattern.matcher(str).matches();
    }
}

Related

  1. isNumber(String s)
  2. isNumber(String s, boolean[] realnum)
  3. isNumber(String str)
  4. isNumber(String str)
  5. isNumber(String str)
  6. isNumber(String str)
  7. isNumber(String str)
  8. isNumber(String str)
  9. isNumber(String str, String sign)