手机格式,省份证格式,过滤图标,过滤qq图像

本文介绍了多种场景下正则表达式的使用方法,包括特殊字符过滤、身份证号码验证、手机号码验证、表情符号过滤及密码复杂度检查等,并提供了具体的Java实现代码。
该文章已生成可运行项目,
}
//2.2过滤特殊字符
String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\].·<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]|\n|\r|\t";
Pattern p2 = Pattern.compile(regEx);
Matcher m2 = p2.matcher(memberPwd);
boolean find = m2.find();
#==============================================================
身份证的验证:
//身份证
Pattern p1=Pattern.compile("(^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{2}$)");
Matcher m1 = p1.matcher(industryAssociation.getCard());
if (!m1.matches()) {
   return SpringMVCUtils.returnError("身份证号格式化不正确");
}#============================================================
手机号的验证:
String trim = mobiles.trim();
Pattern p = Pattern.compile("^((13[0-9])|(14[0-9])|(15[^4,\\D])|(17[0-9])|(18[0-9])|(19[0-9]))\\d{8}$");
Matcher m = p.matcher(mobiles);
System.out.println(m.matches()+"---");
#==============================================================
表情符号:
// 3.过滤表情符号
password.replaceAll("[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]", "");
user.setPassword(MD5.getMD5Str(password));
result = iUserService.updatePassword(user);
result.setCode("200");
#=================================================================
判断全是否全是数字,字符设置密码时提示

// 判断注册的密码不能全是数字或者全是字符
Pattern patternNum = Pattern.compile("[0-9]+");
Pattern patterStr = Pattern.compile("[a-zA-Z]+");
#=============================================================
qq表情包的处理:
// 判断QQ表情的正则表达式  
String qqfaceRegex = "/::\\)|/::~|/::B|/::\\||/:8-\\)|/::<|/::$|/::X|/::Z|/::'\\(|/::-\\||/::@|/::P|/::D|/::O|/::\\(|/::\\+|/:--b|/::Q|/::T|/:,@P|/:,@-D|/::d|/:,@o|/::g|/:\\|-\\)|/::!|/::L|/::>|/::,@|/:,@f|/::-S|/:\\?|/:,@x|/:,@@|/::8|/:,@!|/:!!!|/:xx|/:bye|/:wipe|/:dig|/:handclap|/:&-\\(|/:B-\\)|/:<@|/:@>|/::-O|/:>-\\||/:P-\\(|/::'\\||/:X-\\)|/::\\*|/:@x|/:8\\*|/:pd|/:<W>|/:beer|/:basketb|/:oo|/:coffee|/:eat|/:pig|/:rose|/:fade|/:showlove|/:heart|/:break|/:cake|/:li|/:bome|/:kn|/:footb|/:ladybug|/:shit|/:moon|/:sun|/:gift|/:hug|/:strong|/:weak|/:share|/:v|/:@\\)|/:jj|/:@@|/:bad|/:lvu|/:no|/:ok|/:love|/:<L>|/:jump|/:shake|/:<O>|/:circle|/:kotow|/:turn|/:skip|/:oY|/:#-0|/:hiphot|/:kiss|/:<&|/:&>";  
Pattern p = Pattern.compile(qqfaceRegex);  
Matcher m = p.matcher(content);  
if (m.matches()) {  
    result = true;  
}  

本文章已经生成可运行项目
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值