码迷,mamicode.com
首页 > 其他好文 > 详细

正则匹配查找模板

时间:2017-08-06 12:53:37      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:tar   group   row   pattern   contains   match   word   log   查找   

Pattern  p=Pattern.compile("[a-zA-Z0-9]+");
Matcher w=p.matcher(str);
            while(w.find()){
                String word=w.group();
                int index=w.start();
                if(!dictionary.containsKey(word)){
                    ArrayList<Location> list=new ArrayList<Location>();
                    dictionary.put(word, list);
                }
                ArrayList<Location> list=dictionary.get(word);
                Location pair=new Location(row,index);
                list.add(pair);
                dictionary.put(word, list);
                //System.out.println(index);
            }

 

正则匹配查找模板

标签:tar   group   row   pattern   contains   match   word   log   查找   

原文地址:http://www.cnblogs.com/mzybuaa/p/7169245.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!