[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Improve `replace-regexp-in-string' ergonomics?

From: Lars Ingebrigtsen
Subject: Re: Improve `replace-regexp-in-string' ergonomics?
Date: Tue, 12 Oct 2021 15:18:38 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

But!  I totally thought that the limitation was an actual one on our
regexp libraries for groups, and not just a syntax thing.  So if we just
ignore the backref issue, then things should basically Just Work.


(new-and-spiffy-regexp-replace string
                               "\\(foo\\)" "bar\\1"
                               "\\(bar\\)" "foo\\1"

should work just fine, no matter how many of them you have -- you just
have to transpose the groups down to where they were again before doing
the replacement.  (I mean, after creating the mega-regexp and matching
with that.)

It will break down if the user has a lot of actual backrefs in the
matching regexps, but that's quite rare in practice.

(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

reply via email to

[Prev in Thread] Current Thread [Next in Thread]