首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Java中正则表达式证验联系电话(手机)、邮编、邮箱

2012-11-01 
Java中正则表达式验证联系电话(手机)、邮编、邮箱//验证联系电话public boolean checkPhone(String phone){i

Java中正则表达式验证联系电话(手机)、邮编、邮箱

//验证联系电话public boolean checkPhone(String phone){if(phone.matches("\\d{4}-\\d{8}|\\d{4}-\\d{7}|\\d(3)-\\d(8)")){return true;}else if(phone.matches("^[1][3,5]+\\d{9}")){return true;}else{return false; }}//验证邮政编码public boolean checkPost(String post){if(post.matches("[1-9]\\d{5}(?!\\d)")){return true;}else{return false;}}//验证邮箱public boolean checkEmail(String email){if(email.matches("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")){return true;}else{return false;}}
?

热点排行