ITeye博客

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

cbbs · 2011-06-28 10:37 · 编程语言 · Markdown

Pattern p1 = Pattern.compile("(-|[0-9])?[0-9]*(\\.?)[0-9]+"); // 非數字
Matcher m = p1.matcher(str);
boolean b = m.matches(); // matches() 尝试将整个区域与模式匹配

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。