On Wed, Jun 6, 2012 at 10:39 AM, Rico Moorman
Now I am wondering how I would integrate this in the replacement function or how to rewrite it properly.
Looking at the type signature of =~~ (with my limited knowledge) it seems that I would have to "use" RegexMaker adding up the CompOptions needed?
(=~~) :: (RegexMaker Regex CompOption ExecOption source, RegexContext Regex source1 target, Monad m) => source1 -> source -> m target
What's non-obvious and trip a lot of people when they try to use regexes in Haskell is that most regex libraries use the same interface, which is specified in the regex-base and consists of several typeclasses that offers a very high degree of flexibility. =~and =~~ are only the simplified front-ends to this and are pretty inadequate for advanced usages (for instance compile and use multiple time the same regex, you should really avoid =~ in this case, or additional regex compilation options). To see the basic interface, look at Text.Regex.Base.RegexLike : http://hackage.haskell.org/packages/archive/regex-base/latest/doc/html/Text-... . In particular, what you want to do should be done with makeRegexOpts and match (or matchM), note that the available compilation and execution options can vary depending on the regex library you use and for regex-pcre, they're documented there : http://hackage.haskell.org/packages/archive/regex-pcre/latest/doc/html/Text-... -- Jedaï