日期:2014-05-17 浏览次数:20903 次
String s = "123.45";
if (s.matches("[+-]?\\d+([.]\\d{2})")) {
System.out.println("ok");
} else {
System.out.println("error");
}
------解决方案--------------------
String s = "123.45";
if (s.matches("-?\\d+([.]\\d{2})?")) {
System.out.println("ok");
} else {
System.out.println("error");
}
------解决方案--------------------
if(price.matches("/(^[0-9]*$)|(^[0-9]*[.]{1}[0-9]{1,2}$)/")
{
msg="OK:
}
------解决方案--------------------