pString
Returns a Parser that consumes exactly the sequence of characters in string, and fails if the input does not match or is exhausted before the full string is consumed.
Type parameters
U — the user context type threaded through unchanged.
Example
val hello: Parser<Char, String, Unit> = pString("Hello")
val input = ParserInput.of("Hello, World!".toList(), Unit)
when (val result = hello(input)) {
is Success -> println("Matched: ${result.value}") // "Hello"
is Failure -> println(result.message)
}Content copied to clipboard
An empty string always succeeds with "" without consuming any input.
When ignoreCase is true the comparison is case-insensitive and the returned value reflects the actual characters from the input, not the pattern.
Return
a Parser that succeeds with the matched substring, or fails with a diagnostic message.
Parameters
string
the exact sequence of characters to match.
ignoreCase
whether the comparison is case-insensitive. Defaults to false.