help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: multiple search strings in query-replace-regexp


From: Ilya Zakharevich
Subject: Re: multiple search strings in query-replace-regexp
Date: Mon, 9 Oct 2006 21:53:17 +0000 (UTC)
User-agent: trn [how to get a version via %-escapes???] with a custom header

[A complimentary Cc of this posting was sent to
Stefan Monnier 
<monnier@iro.umontreal.ca>], who wrote in article 
<jwvu02epwqf.fsf-monnier+gnu.emacs.help@gnu.org>:
> > How about rereading what I wrote above?  "To make it useful, one needs
> > a function to count the number of parentheses in a given regular
> > expression.  Is there?"
> 
> `regexp-opt-depth' claims to do that.  I believe the version in Emacs-CVS is
> pretty reliable.

Thanks; still, when combining several regexps into one, one needs to
fixup backreferences.  Given the horrible ELisp regexp syntax, this
requires some dirty backwacking...  E.g., I'm not sure I would be able
to do it right first time (hint: the newer CPerl facification of
RegExps would do it very easy with Perl regexps; much harder to do it
with ELisp...).

Hmm, I see that at least in Elist v19, backreferences went only up to
9; sigh...  Well, this is not needed very often, one could just

 (error
  "RegExp limitation hit, try to make pattern(s) with backreferences first")

or some such.

-------

Additionally, when interpolating replacement string, one should also
shift match-group references by corresponding amount; but this is
easier done in the code of interpolator (I hope it is in ELisp, not in
C).

Yours,
Ilya


reply via email to

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