[Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen?

ChrisK haskell at list.mightyreason.com
Mon Mar 16 16:10:08 EDT 2009


Don Stewart wrote:
> tphyahoo:
>> Is there something like subRegex... something like =~ s/.../.../ in
>> perl... for haskell pcre Regexen?
>>
>> I mean, subRegex from Text.Regex of course:
>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-compat
>>
>> Thanks for any advice,
> 
> Basically, we should have it.

Let me open the discussion with all the questions I can quickly ask:

   What should the "subRegex" function do, exactly?
   (Single replacement,global replacement,once per line,...)

   What should the replacement template be able to specify?
   (Can it refer to all text before a match or all text after?)
   (Can it access the start/stop offsets as numbers?)

   Should the replacement template be specified in a "String"?  As an abstract 
data type or syntax tree?  With combinators?

   What happens if the referenced capture was not made?  Empty text?

   How will syntax errors in the template be handled (e.g. referring to a 
capture that does not exist in the regular expression)?

   Will the output text be String? ByteString? ByteString.Lazy? Seq Char?
   Note: String and Strict Bytestrings are poor with concatenation.

   Can the output text type differ from the input text type?

-- 
Chris



More information about the Haskell-Cafe mailing list