[Haskell-cafe] Need help with learning Parsec

Christian Maeder Christian.Maeder at dfki.de
Thu Jul 19 16:10:50 CEST 2012


Am 19.07.2012 15:41, schrieb Simon Hengel:
> On Thu, Jul 19, 2012 at 03:34:47PM +0200, Simon Hengel wrote:
>>      openTag :: Parser String
>>      openTag = char '<' *> many (noneOf ">") <* char '>'

if you disallow empty tags and "/" within tags, then you can avoid the
notFollowedBy construct by:

        openTag = try (char '<' *> many1 (noneOf "/>")) <* char '>'

C.

>>
>>      endTag :: String -> Parser String
>>      endTag str = string "</" *> string str <* char '>'
>
> Well yes, modified to what Christian Maeder just suggested.
>
> Cheers,
> Simon
>




More information about the Haskell-Cafe mailing list