public String findMatch(Pattern pattern,String text,int groupNum){
  Matcher matcher=pattern.matcher(text);
  if (matcher.find()) {
    return matcher.group(groupNum);
  }
 else {
    return null;
  }
}

public String findMatch ( Pattern pattern , String text , int groupNum ) { Matcher matcher = pattern . matcher ( text ) ; if ( matcher . find ( ) ) { return matcher . group ( groupNum ) ; } else { return null ; } }
finds the first match of the specified pattern and returns the specified matched group .
