tags:

views:

283

answers:

2

Despite the ridiculously large number of regex matching engines for Haskell, the only one I can find that will substitute is Text.Regex, which, while decent, is missing a few thing I like from pcre. Are there any pcre-based packages which will do substitution, or am I stuck with this?

+2  A: 

http://sprunge.us/GRFO?hs

Point out glaring mistakes, things that are obviously wrong, et cetera.

sreservoir
Nice! Once you get some feedback and get it into shape, maybe consider sending it as a patch to regex-lite, or failing that, placing it on hackage on its own?
sclv
I intend to rewrite it for a different engine before I do that, because it unfortunately suffers in a pathological case involving zero-width assertions.
sreservoir
So =~ operates on [Char] strings, but all the operations pack the [Char] string to a ByteString? You might as well just expose the ByteString to the caller, so you don't have to `pack` all the time. That's slow.
jrockway
hm. uh, I'll fix that... eventually. or maybe I'll just use `Text.Regex.PCRE` as a base.
sreservoir
+1  A: 

The regular expression API in regex-base is generic to the container of characters to match. Doing some kind of splicing generically to implements substitution would be very hard to make efficient. I did not want to provide a crappy generic routine.

Writing a small function to do the substitution exactly how you want is just a better idea, and it can be written to match your container.

Chris Kuklewicz