正则表达式:字符串判断是不是为数字,包括浮点数,正数,负数

正则表达式:字符串判断是否为数字,包括浮点数,正数,负数
Pattern p1 = Pattern.compile("(-|[0-9])?[0-9]*(\\.?)[0-9]+"); // 非數字
Matcher m = p1.matcher(str);
boolean b = m.matches(); // matches() 尝试将整个区域与模式匹配