public String readWhile ( String accepted ) { int start = cursor ; while ( cursor < str . length ( ) ) { if ( accepted . indexOf ( str . charAt ( cursor ) ) >= 0 ) ++ cursor ; else break ; } return str . substring ( start , cursor ) ; }
Read everything as long as the char occurs in the accepted characters .