正则

写正则时需要用到匹配出多个符合条件的字符串,放入StringBuffer中。返回匹配的字符串

    public static void main(String[] args) {

StringBuffer sb = new StringBuffer();  
    String src = "2234weet<w:t>000001</w:t>233oge";
          String rex = "(<w:t>\\\d*</w:t>)";  
    Pattern pattern = Pattern.compile(rex); Matcher matcher = pattern.matcher(src); System.out.println("matcher.groupCount():" + matcher.groupCount()); while(matcher.find()){      System.out.println(matcher.group());
              String str = m.group();
              String cell = str.substring(5,12);
              sb.append(cell);
              sb.append("#");
}
          sb.toString();
}
posted @ 2015-12-08 10:34  绿油油的小白菜  阅读(172)  评论(0编辑  收藏  举报