Parsec how to find "matches" within a string
For an arbitrary parser myParser
, it's quite easy:
solution = many (let one = myParser <|> (anyChar >> one) in one)
It might be clearer to write it this way:
solution = many loop
where
loop = myParser <|> (anyChar >> loop)
Essentially, this defines a recursive parser (called loop
) that will continue searching for the first thing that can be parsed by myParser
. many
will simply search exhaustively until failure, ie: EOF.
You can use
many ( noneOf "0123456789")
i'm not sure about "noneOf" and "digit" types but you can give e try also to
many $ noneOf digit