求一正则表达

boy_wh520 2006-12-21 04:49:31

判断了一个字符串 必须有 数字 小写字母 大写字母 的正则那位有啊!有的话麻烦给一个参考下!
...全文
158 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
boy_wh520 2006-12-22
  • 打赏
  • 举报
回复
太感谢了!
shine333 2006-12-22
  • 打赏
  • 举报
回复
更正一下,刚才的错了

String regex = "[\\d[^\\p{Alnum}]]*|[\\p{Lower}[^\\p{Alnum}]]*|[\\p{Upper}[^\\p{Alnum}]]*";
// NG
System.out.println("---NG---");
System.out.println(!"abc".matches(regex));
System.out.println(!"ABC".matches(regex));
System.out.println(!"123".matches(regex));
System.out.println(!";, \t".matches(regex));
System.out.println(!";,ABC \t".matches(regex));
System.out.println(!";,abc \t".matches(regex));
System.out.println(!";,123 \t".matches(regex));
// 以下几种情况楼上的没有考虑到
System.out.println(!"a b".matches(regex));
System.out.println(!"A B".matches(regex));
System.out.println(!"1 2".matches(regex));
System.out.println(!";,A;;;BC \t".matches(regex));
System.out.println(!";,a;;;bc \t".matches(regex));
System.out.println(!";,1;;;23 \t".matches(regex));
// OK
System.out.println("---OK---");
System.out.println(!"abc123".matches(regex));
System.out.println(!"ABC123".matches(regex));
System.out.println(!"abcAbc".matches(regex));
System.out.println(!";,abcABC \t".matches(regex));
System.out.println(!";,ABCabc \t".matches(regex));
System.out.println(!";,123ABC \t".matches(regex));
System.out.println(!";,123abc \t".matches(regex));
System.out.println(!";,abc123 \t".matches(regex));
System.out.println(!";,ABC123 \t".matches(regex));
System.out.println(!";,abc123ABC \t".matches(regex));
System.out.println(!";,ab12c ... A34Bc \t".matches(regex));
shine333 2006-12-22
  • 打赏
  • 举报
回复
反过来判断

如果符合“不存在数字字母,或者只有其中一种的”就是错误的

String regex = "[^\\p{Alnum}]*([\\d]*|[\\p{Lower}]*|[\\p{Upper}]*)[^\\p{Alnum}]*";
// NG
System.out.println("---NG---");
System.out.println(!"abc".matches(regex));
System.out.println(!"ABC".matches(regex));
System.out.println(!"123".matches(regex));
System.out.println(!";, \t".matches(regex));
System.out.println(!";,ABC \t".matches(regex));
System.out.println(!";,abc \t".matches(regex));
System.out.println(!";,123 \t".matches(regex));
// OK
System.out.println("---OK---");
System.out.println(!"abc123".matches(regex));
System.out.println(!"ABC123".matches(regex));
System.out.println(!"abcAbc".matches(regex));
System.out.println(!";,abcABC \t".matches(regex));
System.out.println(!";,ABCabc \t".matches(regex));
System.out.println(!";,123ABC \t".matches(regex));
System.out.println(!";,123abc \t".matches(regex));
System.out.println(!";,abc123 \t".matches(regex));
System.out.println(!";,ABC123 \t".matches(regex));
System.out.println(!";,abc123ABC \t".matches(regex));
System.out.println(!";,ab12c ... A34Bc \t".matches(regex));
boy_wh520 2006-12-22
  • 打赏
  • 举报
回复
判断了一个字符串 必须有 数字 小写字母 大写字母
至少2种的组合
就是说这个字符串
数字+小写 数字+大写 小写+大写 这样的判断 正则有吗?有的话帮忙给个思路
boy_wh520 2006-12-22
  • 打赏
  • 举报
回复
顶一下!希望大家帮帮忙

67,516

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧