question: public static int nextChar ( String s , char needle , int startIndex ) { boolean inSingleQuote = false ; boolean inDoubleQuote = false ; for ( int i = startIndex ; i < s . length ( ) ; ++ i ) { char c = s . charAt ( i ) ; if ( ! inSingleQuote && ! inDoubleQuote && c == needle ) { return i ; } if ( ! inSingleQuote && c == '"' ) { inDoubleQuote ^= true ; } else if ( ! inDoubleQuote && c == '\'' ) { inSingleQuote ^= true ; } } return - 1 ; }
target:  Find the next character 'needle' in the String 's' beginning at 'startIndex'. Needles in parts surrounded with quotes (like attribute values) are ignored.