all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [Fwd: end-of-line $ in multiline regexp replace]
@ 2003-10-31 16:14 Kevin Rodgers
  2003-11-02 23:19 ` Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Rodgers @ 2003-10-31 16:14 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 175 bytes --]

Besides the documentation bug reported below by Alan, search.c:compile_pattern()
ought to report an error when $ is used incorrectly (and ^, \`, \', etc.).

-- 
Kevin Rodgers

[-- Attachment #2: Re: end-of-line $ in multiline regexp replace --]
[-- Type: message/rfc822, Size: 2066 bytes --]

From: Alan Mackenzie<none@example.invalid>
Subject: Re: end-of-line $ in multiline regexp replace
Date: Fri, 31 Oct 2003 08:04:30 +0000
Message-ID: <e25tnb.u8.ln@acm.acm>

Leo <leo.broska@nospam.isys.com.au> wrote on Fri, 31 Oct 2003 11:22:25 +1100:
> hi there

> want to replace a multiline regexp by an one-line replacement. (in fact i
> just want to delete the line with the regexp.)

> so, at first i tried:
>         (query-replace-regexp ".*bytes.*$[ctrl-q][ctrl-j]" "" nil nil nil)
> which did not find any line. :-(

> then i just tried the same without the end-of-line "$":
>         (query-replace-regexp ".*bytes.*[ctrl-q][ctrl-j]" "" nil nil nil)
> and that worked.

> i don't understand, why? the first regexp ".*bytes.*$[ctrl-q][ctrl-j]" seems
> to me even >>more valid<< then the second one.

> any explanations?

Yes.  It's on the page "Regexp Special" in the Elisp manual:

:      For historical compatibility reasons, `$' can be used only at the
:      end of the regular expression, or before `\)' or `\|'.

I think this is crazy, but there you go.  There is no matching warning on
the corresponding page ("Regexps") in the Emacs manual (at least, there
wasn't in October 2001), which seems like a bug to me.

A workaround is to enclose such a `$' in parentheses:  "\($\)" [or
"\\($\\)" if you're writing it as a string in a Lisp program].

> tanks and cheers, leo

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").


[-- Attachment #3: Type: text/plain, Size: 148 bytes --]

_______________________________________________
Bug-gnu-emacs mailing list
Bug-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Fwd: end-of-line $ in multiline regexp replace]
  2003-10-31 16:14 [Fwd: end-of-line $ in multiline regexp replace] Kevin Rodgers
@ 2003-11-02 23:19 ` Richard Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2003-11-02 23:19 UTC (permalink / raw)
  Cc: bug-gnu-emacs

    Besides the documentation bug reported below by Alan, search.c:compile_pattern()
    ought to report an error when $ is used incorrectly (and ^, \`, \', etc.).

It is not an error to use $ in other contexts.  However, the $ matches
literally in those contexts.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-11-02 23:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-31 16:14 [Fwd: end-of-line $ in multiline regexp replace] Kevin Rodgers
2003-11-02 23:19 ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.