Java Regex Number Validate isNumber(String str)

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

Description

Methods Descrip:

License

LGPL

Parameter

Parameter Description
str a parameter

Declaration

public static boolean isNumber(String str) 

Method Source Code

//package com.java2s;
/**/*from  w ww.  j  av  a 2 s  . com*/
 *
 * Methods Descrip:Converts a line of text into an array of lower case words
 * using a BreakIterator.wordInstance().
 * <p>
 *
 * This method is under the Jive Open Source Software License and was
 * written by Mark Imbriaco.
 *
 * @param text
 *            a String of text to convert into an array of words
 * @return text broken up into an array of words.
 *
 */

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

public class Main {
    /**
     *
     * Methods Descrip:
     *
     * @param str
     * @return
     *
     */
    public static boolean isNumber(String str) {
        boolean flag = false;
        if (str == null || str.equals("")) {
            return false;
        }
        Pattern p = Pattern.compile("[0-9]*");
        ;
        Matcher m = p.matcher(str);
        ;
        flag = m.matches();
        return flag;
    }
}

Related

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