使用正则匹配字符串的子串

来源:互联网 发布:淘宝里面最大霸王坑 编辑:程序博客网 时间:2024/05/01 23:27

使用正则表达式可以匹配出一段字符串中我们需要的子串

public static void FindSbuString(){

               String sRegex="([a-zA-Z]+)-([0-9]+)";
               Pattern oPattern=Pattern.compile(sRegex);
               Matcher oMatcher=oPattern.matcher(_logMsg);
  
                while(oMatcher.find()){
                               System.out.println("matcher:"+oMatcher.group());
                }

}

原创粉丝点击