- public static List<Map<Integer,String>> getRegResult(String content,String regX){
- if(content==null || content.equals("")) return null;
- if(regX==null || regX.equals("")) return null;
- List<Map<Integer,String>> list = new ArrayList<Map<Integer,String>>();
- Matcher m = Pattern.compile(regX).matcher(content);
- while(m.find()){
- Map<Integer,String> mp = new HashMap<Integer,String>();
- int gc = m.groupCount();
- if(gc>0){
- for(int k=1; k <= gc; k++){
- mp.put(k, m.group(k));
- //System.out.println("k=="+k+"---->>"+m.group(k));
- }
- list.add(mp);
- }
- }
- return list;
- }
- //该片段来自于http://www.codesnippet.cn/detail/1011201410925.html
来源: http://www.codesnippet.cn/detail/1011201410925.html