验证money类型的正则该怎么写? RT比如 100 要能过 100.5 也要能过.现在的处理是让他match "\\d+" 也就是int型 或者 match "\\d+\\.?\\d+" 也就是带小数点的能不能写成一个正则表达式. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 (\\.[\\d]+)|([\\d]+\\.[\\d]+)|([\\d]+)测试.510.510通过 在java里面 是不是要写成 ([\\d]+)(\\.[\\d]{0,2})?要不会报错 package net.xiaobin.test;import java.util.regex.Pattern;public class RegexTest { private static void run(String args) { Pattern fPattern = Pattern.compile("^\\d{1,}\\.\\d{1,2}$"); Pattern iPattern = Pattern.compile("^\\d{1,}$"); if (fPattern.matcher(args).find()) { System.out.println(args + ":浮点型"); } else if (iPattern.matcher(args).find()) { System.out.println(args + ":整型"); } else { System.out.println(args + ":类型未知"); } } public static void main(String[] args) { run("0.01"); run("0.001"); run("100.03"); run("50"); run("50.1"); }} null被强制转化为字符? 一个JFrame程序怎么修改,添加到一个程序的JPanel中? 关于记事本查找显示的问题 加密解密问题 Sun认证Java程序员(SCJP) 请问怎样生成JAVA的exe文件? 如何取出Map对象的所有值? 问个画圆的问题!我想画个饼图 请教>>>的问题~ 晕了!!!!!!又是100个错误??????晕了??????(编译器没有问题)???????? 求Java文件发送和接收端原代码,最好是GUI的 jsp 如何,用正则表达式。获取<img src=0.gif>中的0.gif??????????
.5
10.5
10
通过
要不会报错
Pattern fPattern = Pattern.compile("^\\d{1,}\\.\\d{1,2}$");
Pattern iPattern = Pattern.compile("^\\d{1,}$");
if (fPattern.matcher(args).find()) {
System.out.println(args + ":浮点型");
} else if (iPattern.matcher(args).find()) {
System.out.println(args + ":整型");
} else {
System.out.println(args + ":类型未知");
}
} public static void main(String[] args) {
run("0.01");
run("0.001");
run("100.03");
run("50");
run("50.1");
}
}