ParseCtxt { public String readCharsAndAdvanceUntil(char... charsToStopBefore) { StringBuilder sb = new StringBuilder(); do { if (isDone()) { throw new ParseException(this, "Unexpected end of expression. One of the following characters expected: {" + charArrayToHumanReadableString(charsToStopBefore) + "}"); } if (ArrayUtils.contains(charsToStopBefore, text.charAt(pos))) { break; } else { sb.append(readCharAndAdvance()); } } while (true); return sb.toString().replaceAll("\\s+",""); } ParseCtxt(String text);  ParseCtxt(String text, SyntaxVersion syntaxVersion); final boolean isDone(); static boolean isSpace(char ch); final ParseCtxt skipBlanks(); final boolean isOnChar(char ch); final char currentChar(); final void readChar(char ch); final boolean testAndReadChar(char ch); final char readCharAndAdvance(); String readCharsAndAdvanceUntil(char... charsToStopBefore); final String skipBlanksAndReadNameString(); final String readNameString(); boolean isNameStartChar(char ch); boolean isNameMiddleChar(char ch); void readString(String s); boolean readOptionalString(String s); boolean readOptionalChar(char ch); final String readTill(char ch); int getPos(); void setPos(int newPos); String getText(); SyntaxVersion getSyntaxVersion();  }
@Test public void testReadCharsAndAdvanceUntil() { ParseCtxt c = new ParseCtxt("(as:alias,o ) hello"); c.readChar('('); String chars = c.readCharsAndAdvanceUntil(' ', ',', ')'); assertEquals(9, c.getPos()); assertEquals("as:alias", chars); c.readChar(','); chars = c.readCharsAndAdvanceUntil(' ', ',', ')'); assertEquals(11, c.getPos()); assertEquals("o", chars); }