public String readUntil(final char... end)
    {
        final StringBuilder sb = new StringBuilder();
        int pos = this.pos;
        while (pos < this.value.length())
        {
            final char ch = this.value.charAt(pos);
            if (ch == '\\' && pos + 1 < this.value.length())
            {
                final char c;
                switch (c = this.value.charAt(pos + 1))
                {
                case '\\':
                case '[':
                case ']':
                case '(':
                case ')':
                case '{':
                case '}':
                case '#':
                case '"':
                case '\'':
                case '.':
                case '>':
                case '*':
                case '+':
                case '-':
                case '_':
                case '!':
                case '`':
                case '~':
                    sb.append(c);
                    pos++;
                    break;
                default:
                    sb.append(ch);
                    break;
                }
            }
            else
            {
                boolean endReached = false;
                for (int n = 0; n < end.length; n++)
                {
                    if (ch == end[n])
                    {
                        endReached = true;
                        break;
                    }
                }
                if (endReached)
                {
                    break;
                }
                sb.append(ch);
            }
            pos++;
        }

        final char ch = pos < this.value.length() ? this.value.charAt(pos) : '\n';
        for (int n = 0; n < end.length; n++)
        {
            if (ch == end[n])
            {
                this.pos = pos;
                return sb.toString();
            }
        }
        return null;
    }
public String readUntil ( final char ... end ) { final StringBuilder sb = new StringBuilder ( ) ; int pos = this . pos ; while ( pos < this . value . length ( ) ) { final char ch = this . value . charAt ( pos ) ; if ( ch == '\\' && pos + 1 < this . value . length ( ) ) { final char c ; switch ( c = this . value . charAt ( pos + 1 ) ) { case '\\' : case '[' : case ']' : case '(' : case ')' : case '{' : case '}' : case '#' : case '"' : case '\'' : case '.' : case '>' : case '*' : case '+' : case '-' : case '_' : case '!' : case '`' : case '~' : sb . append ( c ) ; pos ++ ; break ; default : sb . append ( ch ) ; break ; } } else { boolean endReached = false ; for ( int n = 0 ; n < end . length ; n ++ ) { if ( ch == end [ n ] ) { endReached = true ; break ; } } if ( endReached ) { break ; } sb . append ( ch ) ; } pos ++ ; } final char ch = pos < this . value . length ( ) ? this . value . charAt ( pos ) : '\n' ; for ( int n = 0 ; n < end . length ; n ++ ) { if ( ch == end [ n ] ) { this . pos = pos ; return sb . toString ( ) ; } } return null ; }
TODO use Util#readUntil