Attoparsec provides the function skipSpace
.
This function consumes all whitespace available.
How can I implement a function skipSpaceNoNewline
that skips any whitespace except \n
and \r\n
?
Note: This question intentionally shows no research effort as it was answered Q&A-Style.
You can combine skipWhile
and isEndOfLine
(which matches both \n
and \r\n
).
Using a lambda function, you can combine them to a skipWhile
predicate that skips any whitespace except newlines.
skipSpaceNoNewline = skipWhile (\x -> isSpace_w8 x && not (isEndOfLine x))