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.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static boolean isNumber(String str) {
        boolean res = false;
        if (str != null && str.length() > 0) {
            Pattern pattern = Pattern.compile("^\\d+$");
            Matcher m = pattern.matcher(str);
            if (m.find()) {
                res = true;/*ww  w  . j a v a2  s.c  o m*/
            }
        }
        return res;
    }
}

Related

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