public static int match(String buf,String[] regexs,String[] groups,int flags){
  int index=0;
  for (  String regex : regexs) {
    Pattern p=Pattern.compile(regex,flags);
    Matcher m=p.matcher(buf);
    if (m.matches()) {
      int ngroups=m.groupCount();
      for (int j=1; j <= ngroups; j++) {
        groups[j - 1]=m.group(j);
      }
      return index;
    }
    index++;
  }
  return -1;
}

public static int match ( String buf , String [ ] regexs , String [ ] groups , int flags ) { int index = 0 ; for ( String regex : regexs ) { Pattern p = Pattern . compile ( regex , flags ) ; Matcher m = p . matcher ( buf ) ; if ( m . matches ( ) ) { int ngroups = m . groupCount ( ) ; for ( int j = 1 ; j <= ngroups ; j ++ ) { groups [ j - 1 ] = m . group ( j ) ; } return index ; } index ++ ; } return - 1 ; }
returns the index of the first regex that matches the buffer . if none match , returns - 1 . any regex group outputs are returned in groups . the matching text is removed from the buffer .
