标签:
/** *验证电子邮件?手机号码?密码6-15位?验证输入网址?身份证号?邮编? *邮箱正则: *"[\\w]@[\\w](.\\w+)+"; */ public class StringDemo8 { public static void main(String[] args) { String email = "99999999@qq.com.cn"; String emailRegex = "[\\w]+@[a-zA-z0-9]+(.\\w+)+"; String pwdRegex = "[\\w]{6,15}"; String pwd = "a_34625"; String idRegex = "[2]([\\d]{17}|[\\d]{14}|[\\d]{16}[xX])"; String id = "21010219880313212X"; String jpgImg = "mqh.jpg"; String jpgRegex = "\\."; System.out.println(email.matches(emailRegex)); System.out.println(pwd.matches(pwdRegex)); System.out.println(id.matches(idRegex)); //自动改文件名的小应用 String[] newName = jpgImg.split(jpgRegex); jpgImg = System.currentTimeMillis()+"."+newName[1]; System.out.println(jpgImg); //替换掉骂人脏话的方法的应用 String fuck = "我想说: cnm,fuck dsb"; String fuckRegex = "fuck|Sb|cnm|dsb"; fuck = fuck.replaceAll(fuckRegex, "***"); System.out.println(fuck); } }
验证电子邮件?手机号码?密码6-15位?验证输入网址?身份证号?邮编? 文件改名? 替换字符串部分单词?
标签:
原文地址:http://www.cnblogs.com/zyjcxc/p/5450213.html