public static boolean isNumber(String string){
  final String Digits="(\\p{Digit}+)";
  final String HexDigits="(\\p{XDigit}+)";
  final String Exp="[eE][+-]?" + Digits;
  final String fpRegex=("[\\x00-\\x20]*" + "[+-]?(" + "NaN|"+ "Infinity|"+ "(((" + Digits + "(\\.)?("+ Digits+ "?)("+ Exp+ ")?)|"+ "(\\.("+ Digits+ ")("+ Exp+ ")?)|"+ "(("+ "(0[xX]"+ HexDigits+ "(\\.)?)|"+ "(0[xX]"+ HexDigits+ "?(\\.)"+ HexDigits+ ")"+ ")[pP][+-]?"+ Digits+ "))"+ "[fFdD]?))"+ "[\\x00-\\x20]*");
  return Pattern.matches(fpRegex,string);
}

public static boolean isNumber ( String string ) { final String Digits = "(\\p{Digit}+)" ; final String HexDigits = "(\\p{XDigit}+)" ; final String Exp = "[eE][+-]?" + Digits ; final String fpRegex = ( "[\\x00-\\x20]*" + "[+-]?(" + "NaN|" + "Infinity|" + "(((" + Digits + "(\\.)?(" + Digits + "?)(" + Exp + ")?)|" + "(\\.(" + Digits + ")(" + Exp + ")?)|" + "((" + "(0[xX]" + HexDigits + "(\\.)?)|" + "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" + ")[pP][+-]?" + Digits + "))" + "[fFdD]?))" + "[\\x00-\\x20]*" ) ; return Pattern . matches ( fpRegex , string ) ; }
returns true if the string parameter represents a valid number . < p > the body of this method is taken from the javadoc documentation for the java double class .
