From: Eli Zaretskii <eliz@gnu.org>
To: jan <rtm443x@googlemail.com>
Cc: 21995-done@debbugs.gnu.org
Subject: bug#21995: Documentation omission for regular expressions
Date: Mon, 23 Nov 2015 19:02:21 +0200 [thread overview]
Message-ID: <83610s1wf6.fsf@gnu.org> (raw)
In-Reply-To: <CADJx9LcyZCfFFhEnxzaJQR7sC2XO1pxH7Bupis6TpByyNPT=Qw@mail.gmail.com>
> Date: Mon, 23 Nov 2015 12:16:59 +0000
> From: jan <rtm443x@googlemail.com>
>
> \& used as a replacement will substitute in the entire matched
> pattern. For example, given text
>
> hello
>
> and search regexp \(.\) with replacement \&\& you get
>
> hheelloo
>
> I have not been able to find this \& option in the regular expression
> part of the emacs manual.
It's described in the node "Regexp Replace" (since it's only relevant
to replacing a matched regexp). Quote:
`M-x replace-regexp <RET> REGEXP <RET> NEWSTRING <RET>'
Replace every match for REGEXP with NEWSTRING.
In `replace-regexp', the NEWSTRING need not be constant: it can
refer to all or part of what is matched by the REGEXP. `\&' in
NEWSTRING stands for the entire match being replaced. `\D' in
NEWSTRING, where D is a digit, stands for whatever matched the Dth
parenthesized grouping in REGEXP. (This is called a "back reference".)
`\#' refers to the count of replacements already made in this command,
as a decimal number. In the first replacement, `\#' stands for `0'; in
the second, for `1'; and so on. For example,
prev parent reply other threads:[~2015-11-23 17:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-23 12:16 bug#21995: Documentation omission for regular expressions jan
2015-11-23 17:02 ` Eli Zaretskii [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=83610s1wf6.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=21995-done@debbugs.gnu.org \
--cc=rtm443x@googlemail.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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).