unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Edward Dodge <someone@g3.com>
Subject: Re: end-of-line $ in multiline regexp replace
Date: Fri, 31 Oct 2003 10:50:07 -0600	[thread overview]
Message-ID: <m1sml973nk.fsf@g3.com> (raw)
In-Reply-To: bnsa84$1e1p$1@otis.netspace.net.au

"Leo" <leo.broska@NOSPAM.isys.com.au> writes:

> 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?
>
> tanks and cheers, leo

The $ meta-character represents the very end of a line, which would
include the newline character.  Whereas C-q C-j is a regular
expression for the newline character.  My guess is that $ marks the
very end of the line (INCLUDING the newline character) and so your
regexp is actually the equivalent of this:

".*bytes.*[ctrl-q][ctrl-j][ctrl-q][ctrl-j]"

-- 
Edward Dodge

/GNU Emacs 21.3.50.1 (powerpc-apple-darwin5.5) of 2002-10-11 on G3/

      parent reply	other threads:[~2003-10-31 16:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-31  0:22 end-of-line $ in multiline regexp replace Leo
2003-10-31  8:04 ` Alan Mackenzie
2003-10-31 16:50 ` Edward Dodge [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1sml973nk.fsf@g3.com \
    --to=someone@g3.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).