[Top][All Lists]

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

Re: query-replace-interactive not documented

From: David Kastrup
Subject: Re: query-replace-interactive not documented
Date: 16 Jun 2004 11:01:13 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Juri Linkov <address@hidden> writes:

> Andreas Schwab <address@hidden> writes:
> >> +   (if (string-match "\\\\'" to-string)
> >> +       (let (to expr)
> >> +         (while (string-match "\\\\'" to-string)
> >
> > That needs more careful treatment, to handle cases like "\\\\'" where one
> > wants to substitute a backslash followed by a single quote.
> It seems the regexp from David's version handles it right:
> (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\`")
> Do you see any problems with it?

Somebody has a pattern matching problem.  He says "I know, I'll use
regular expressions for it".  Now he has two problems.  SCNR.

In short: it is not beautiful, but I don't see how this could be
improved.  And a problem with the above is that \` only matches at
position 0 of a string, not at the point where you start matching.  So
you need to explicitly digest the string with "substring" while
parsing to keep this working.

Perhaps the starting index of a string match should match on \= in
analogy to the "starting index" of a buffer match?

But that's just an aside note.

David Kastrup, Kriemhildstr. 15, 44793 Bochum

reply via email to

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