protected String findAll ( String strPattern , String text , int grp , String separator ) { String retval = "" ; boolean firstTime = true ; Pattern pattern = Pattern . compile ( strPattern ) ; Matcher matcher = pattern . matcher ( text ) ; while ( matcher . find ( ) ) { retval += ( firstTime ? "" : separator ) + matcher . group ( grp ) ; firstTime = false ; } return retval ; }
Finds all occurences of a pattern in a piece of text and returns the matching groups .