Given some strings: "\begin", "\end" or "\section" etc.
I want to match them with following function and regular expression:
matchTest (mkRegex '\\[:alnum:]+') "\begin"
I always get False when I test it in GHCi,
Does anyone know how to match the pattern like "\begin" or "\end" etc.
> matchTest (mkRegex "\\\\[a-zA-Z0-9]+") "\\begin"
True
There are a couple of issues with your line of code.
regex-compat (I assume that's the package you're using) are the same as those supported by egrep, and they don't know :alnum:.\ is an escape character both within Haskell strings and regular expressions, so you need to escape it.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With