社区
Java EE
帖子详情
求一正则表达
boy_wh520
2006-12-21 04:49:31
判断了一个字符串 必须有 数字 小写字母 大写字母 的正则那位有啊!有的话麻烦给一个参考下!
...全文
165
5
打赏
收藏
求一正则表达
判断了一个字符串 必须有 数字 小写字母 大写字母 的正则那位有啊!有的话麻烦给一个参考下!
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用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
打赏
举报
回复
顶一下!希望大家帮帮忙
(中小学教育)三年级下册语文园地一正稿.ppt
这正是《三年级下册语文园地一正稿.ppt》课件所要传达的核心理念。该课件旨在通过一系列精心设计的课程内容,帮助学生在语文学习的道路上稳步前行,特别是关注了词汇、量词和成语的学习与应用。 首先,课件中“我的...
驴唇马嘴的成语.docx
而与之相对的反义成语“有板有眼”,则是对那些说话有条理、逻辑严密的
表达
的高度赞扬。这一正一反两种成语,为我们提供了评价言语
表达
准确与否的标准。 为了更好地理解和运用“驴唇马嘴”这一成语,我们不妨通过...
初中文言文分类复习.doc
其中,《权劝学》和《伤仲永》对比阅读,一正一反地说明了学习对个人成长的影响。 山水篇如《山市》、《三峡》、《答钟书书》等描绘了壮丽的自然景观,以
表达
作者的情感。这些游记和名胜记有的以“记”为体裁,有的...
江苏省沭阳县修远中学2020届高三数学9月月考试题理含解析
正弦定理适用于已知两边及其夹角求第三边的情况,而余弦定理则用于求解边长或角度关系。 三角函数的诱导公式和同角三角函数关系是解决三角函数值问题的基础。通过对特定角度的三角函数值进行变换,可以求解出其他...
全国通用2016版高考数学大二轮总复习增分策略第四篇第4讲数列不等式
在求最值问题时,要遵循“一正、二定、三相等”的原则。 通过这些问题的解析,我们可以看到,无论是数列还是不等式,都需要扎实的基础知识和灵活的应用技巧。对于高考考生来说,理解和掌握这些知识点,能够有效提升...
Java EE
67,543
社区成员
225,859
社区内容
发帖
与我相关
我的任务
Java EE
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
复制链接
扫一扫
分享
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章