社区
Java EE
帖子详情
求一正则表达
boy_wh520
2006-12-21 04:49:31
判断了一个字符串 必须有 数字 小写字母 大写字母 的正则那位有啊!有的话麻烦给一个参考下!
...全文
180
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
打赏
举报
回复
顶一下!希望大家帮帮忙
[**百分
求一
正则
表达
式**]
求一
金额验证的
正则
表达
式!!!
导读: 要求: 通过验证的可以是带逗号的数字形式:如 4,123 479,568,456.56 也可以是不带逗号的,如 4123 479568456.56 另外0,负号都是能通过的,如 0 0.00 -4567 -4,567 还有就是有小数最多两位,以下都是能通过的,如 123.1 123.10 123.00 456,78
php
正则
替换表情,
求一
正则
表达
式,替换某一规则的表情符号为表情图标(
表情)...
求一
正则
表达
式,替换某一规则的表情符号为表情图标(表情) [高兴] 替换为 (用中文命名图片规不规范?) 其实最好还是用JS来比较好的。回复讨论(解决方案)$str='[高兴]表情图片';echo preg_replace('/\[(.*)\]/',"",$str); 这年头,什么都
正则
...用中文名做文件名的确不是明智的做法.function replaceStr($str){$str=s...
oracle
正则
表达
式 只含数字,
求一
正则
表达
式,字符串中含有中文和特殊字符,只保留英文和数字即可...
Try!SQL> with t as2(3 select 'uuuuuu777777QQQQQ-*~7777' str from dual4 union all5 select 'SAP@R/3_+_HAHA' from dual6 union all7 select '12_889@Intel/Abap/4_Sap' from dual8 union all9...
java
正则
替换非数字和字母_
求一
正则
表达
式,去掉非数字(0-9),字母(a-z, A-Z),下划线(_)和横线(-)的其他所有字符。...
展开全部求法:var reg="^32313133353236313431303231363533e58685e5aeb931333433626462[A-Za-z0-9-_]+$" ;varregus = new RegExp(regs);regus.test("所要验证的字符串")true符合 false 不符合。中英文数字和下划线,横线的var regH = "^[\u4e00-\u9...
Java EE
67,535
社区成员
225,852
社区内容
发帖
与我相关
我的任务
Java EE
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
复制链接
扫一扫
分享
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章