第一种验证方式
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
原文地址:http://zhoum1118.blog.51cto.com/10054110/1650548