
Hi Roly,
I'm looking for a simple way to rewrite strings according to simple composable rules like:
replace "_" by "\\(\\hole\\)" replace "-n" where n matches an integer by "^{n}"
so that I can import some pretty-printed output into a LaTeX alltt environment. I'm guessing that this nice functional stream transformation problem has been solved thousands of times. Could anyone point me to a simple package that would do this for me?
you can try the regex-xmlschema package on Hackage: http://hackage.haskell.org/package/regex-xmlschema-0.1.3 -- ---------- import Text.Regex.XMLSchema.String replace1 :: String -> String replace1 = sed (const "\\(\\hole\\)") "_" replace1 :: String -> String replace2 = sed (\ x -> "^{" ++ x ++ "}") "-[0-9]+" -- ----------- will solve your task Regards, Uwe