pTakeWhile

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

Returns a Parser that consumes zero or more characters satisfying predicate, collecting them into a String. Always succeeds; returns an empty string when predicate is false for the first character or the input is exhausted.

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

Return

a Parser that always succeeds with the matched substring.

Parameters

predicate

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

See also