pTakeWhile1

fun <U : Any> pTakeWhile1(predicate: (Char) -> Boolean): Parser<Char, String, U>

Returns a Parser that consumes one or more characters satisfying predicate, collecting them into a String. Fails when predicate is false for the first character or the input is exhausted.

Equivalent to pMap(pMany1(pSatisfy(predicate))) { it.joinToString("") }.

Return

a Parser that succeeds with a non-empty matched substring, or fails.

Parameters

predicate

the test applied to each character; consumption stops on the first character for which it returns false.

See also