On Tue, Dec 3, 2019 at 7:24 AM Chris Hanson <xxxxxx@chris-hanson.org> wrote:
The definition of regexp-replace specifies the meanings of ‘pre and ‘post as substitution arguments.

What I expect is that ‘pre/‘post will transform into

(substring string start (regexp-match-submatch-start match 0))
(substring string (regexp-match-submatch-end match 0) end)

However, looking at the chibi implementation (the only one I’ve found after 10 minutes of searching), what these transform into is

Were you hoping to find others or did you have trouble finding the reference implementation?  It is linked from the SRFI document.

A complete regexp engine is quite a bit of work so it's unsurprising if there are no other impls, though borrowing sre->pcre and wrapping another impl is reasonable.

(substring string 0 (regexp-match-submatch-start match 0))
(substring string (regexp-match-submatch-end match 0) (string-length string))

I suspect that this is a bug, given this sentence in the description:

The optional parameters start and end restrict both the matching and the substitution, to the given indices, such that the result is equivalent to omitting these parameters and replacing on (substring str start end)

But I’d appreciate confirmation of this. It might also be good to clarify what happens here.

Yes, thanks for catching this, 'pre/'post should respect start and end.  I will fix this.

--
Alex