首页 > 其他 > 详细

正则验证:Pattern,Matcher

时间:2015-12-25 16:35:13      阅读:115      评论:0      收藏:0      [点我收藏+]
 1     public static void main(String[] args) {
 2         String regex="([a-z]{1})(\\d{2})";
 3         String candidate = "sdsdx99sdsdc99Supr99erJau99va";
 4         Pattern p=Pattern.compile(regex);
 5         Matcher matcher=p.matcher(candidate);
 6         while(matcher.find()){
 7             int n=matcher.groupCount();
 8 //            for(int i=0;i<=n;i++){
 9 //                String str=matcher.group(i);
10 //                System.out.println(str);
11 //            }
12             
13             
14             System.out.println(n);
15         }
16 //        matcher.reset();
17 //        System.out.println(matcher.group());
18 //        
19 //        
20 //        System.out.println(matcher.replaceAll("xulu"));
21         
22     }

 

正则验证:Pattern,Matcher

原文:http://www.cnblogs.com/xxwn/p/5076160.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!