java 正则表达式 信息验证

时间:2015-05-12 19:18:55   收藏:0   阅读:141
第一种验证方式
Pattern p = Pattern.compile("模式");
 Matcher m = p.matcher("要验证的信息");
 boolean b = m.matches();
 第二种验证方式
 boolean b = Pattern.matches("模式", "要验证的信息");
 第三中验证方式
 boolean b = src.matches("^http://.*")

例如:要验证信息String src是否是http格式,则可以用:boolean b = Pattern.matches("^http://.*",src);

详细:http://www.jb51.net/article/15364.htm

本文出自 “程序猿进阶攻城狮” 博客,请务必保留此出处http://zhoum1118.blog.51cto.com/10054110/1650548

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!