
Hello, I have a given piece of multiline HTML (which is generated using pandoc btw.) and I am trying to wrap certain elements (tags with a given class) with a <div>. I already took a look at the Text.Regex.PCRE module which seemed a reasonable choice because I am already familiar with similar regex implementations in other languages. I came up with the following function which takes a regex and replaces all matches within the given string using the provided function (which I would use to wrap the element) import Text.Regex.PCRE ((=~~)) -- Replaces the whole match for the given regex using the given function regexReplace :: String -> (String -> String) -> String -> String regexReplace regex replace text = go text where go text = case text =~~ regex of Just (before, match, after) -> before ++ replace match ++ go after _ -> text The problem with this function is, that it will not work on multiline strings. I would like to call it like this: newBody = regexReplace "