要求输入中:
1, 只能是数字或*
2, 不能存在两个连着的*
3, 至少存在一组连着的三个数字
1, 只能是数字或*
2, 不能存在两个连着的*
3, 至少存在一组连着的三个数字
解决方案 »
- 熟悉hibernate配置文件XML的进来答疑
- struts2.2+spring 2.5+hibernate3 Exception!
- 关于struts2生成验证码问题
- Httpclient 中session问题 - 美女程序员急求答案
- 怎么在MySQL-Front中导入表格
- errors.add("username",new ActionError("error.login.NullUserName"))的疑惑!!!
- oracle sql问题
- 用过Eclipse+Tomcat+lomboz的请看一下
- 我连接SQL2000时,JDBC出问题,提示:aq.executeQuery: [Microsoft][SQLServer 2000 Driver for JDBC]End of stream was de tected on a
- 天下武功唯快不破-Jeecg极速开发平台
- java 进位取整问题
- JAVA 中的集合框架
Pattern pat1=Pattern.compile("[0-9]{3,}");
Pattern pat2=Pattern.compile("\\*?(?:[0-9]{1,}\\*?)+");
return pat1.matcher(str).find()&&pat2.matcher(str).matches();
public class Test{ //1, 只能是数字或*
//2, 不能存在两个连着的*
//3, 至少存在一组连着的三个数字
public static void main(String [] args){
String str = "*" ;
System.out.println(str.matches("^[0-9]{3,}|[*]{0,1}")) ;
}
}
//2, 不能存在两个连着的*
//3, 至少存在一组连着的三个数字
public static void main(String [] args){
String str = "1234*" ;
System.out.println(str.matches("((\\d{0,2}[*]{0,1}((\\d)|$)){0,}(([*]{0,1}\\d{3,}){1,}(([*]\\d{1,})|(\\d)|($)))(\\d{0,2}[*]{0,1}((\\d)|$)){0,})")) ;
}
}
我以前用过的哦