why no replace function in our regular expression libs ?

People have put a lot of work into regular expression libraries on haskell. Yet it seems very few of them provide a replace/substitute function - just regex-compat and regepr as far as I know. Why is that ? #haskell says: <sclv> iirc its because that's a really mutatey operation in the underlying c libs <sclv> should be simple enough to write a general purpose wrapper layer that uses captures to create the effect Secondly, as of today what do y'all do when you need that functionality ? -Simon

I've needed this recently, too.
End result: I wrote an "Attoparsec.Parser Text", and ran the text through
that.
A regex would have been much nicer...
- Clark
On Fri, Jan 25, 2013 at 2:06 PM, Simon Michael
People have put a lot of work into regular expression libraries on haskell. Yet it seems very few of them provide a replace/substitute function - just regex-compat and regepr as far as I know. Why is that ? #haskell says:
<sclv> iirc its because that's a really mutatey operation in the underlying c libs <sclv> should be simple enough to write a general purpose wrapper layer that uses captures to create the effect
Secondly, as of today what do y'all do when you need that functionality ?
-Simon
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 13-01-25 02:06 PM, Simon Michael wrote:
People have put a lot of work into regular expression libraries on haskell. Yet it seems very few of them provide a replace/substitute function - just regex-compat and regepr as far as I know. Why is that ? [...] Secondly, as of today what do y'all do when you need that functionality
I can only speak for myself, why I do not miss regex substitution too much. Sometimes, regex substitution is exactly the solution, and I use it. But the whole job is easily done in a shell script, or even in an editor. So I don't use regex substitution in Haskell in this case. Sometimes, the substitution job is: transform this <article> <title><code>Monad</code> Tutorial</title> <content>...</content> </article> to this <!DOCTYPE html etc etc> <html> <head><title>Monad Tutorial</title></head> <body> <h1><code>Monad</code> Tutorial</h1> ... </body> </html> In this job, if a regex solution exists, I don't want to know. I just use HXT or XSLT. Sometimes, regex substitution plus Haskell is exactly the solution. Then I use regex-compat. It works. One solution is enough. I don't need a hundred choices for regex, or a hundred choices for Int.
participants (3)
-
Albert Y. C. Lai
-
Clark Gaebel
-
Simon Michael