it can refer to all or part of what is matched by the @var{regexp}.
@samp{\&} in @var{newstring} stands for the entire match being
replaced. @samp{\@var{d}} in @var{newstring}, where @var{d} is a
-digit, stands for whatever matched the @var{d}th parenthesized
-grouping in @var{regexp}. (This is called a ``back reference''.)
-@samp{\#} refers to the count of replacements already made in this
-command, as a decimal number. In the first replacement, @samp{\#}
-stands for @samp{0}; in the second, for @samp{1}; and so on. For
-example,
+digit starting from 1, stands for whatever matched the @var{d}th
+parenthesized grouping in @var{regexp}. (This is called a ``back
+reference''.) @samp{\#} refers to the count of replacements already
+made in this command, as a decimal number. In the first replacement,
+@samp{\#} stands for @samp{0}; in the second, for @samp{1}; and so on.
+For example,
@example
M-x replace-regexp @key{RET} c[ad]+r @key{RET} \&-safe @key{RET}
Fourth and fifth arg START and END specify the region to operate on.
-In TO-STRING, `\\&' stands for whatever matched the whole of REGEXP,
-and `\\=\\N' (where N is a digit) stands for
-whatever what matched the Nth `\\(...\\)' in REGEXP.
+In TO-STRING, `\\&' or `\\0' stands for whatever matched the whole of
+REGEXP, and `\\=\\N' (where N is a digit) stands for whatever matched
+the Nth `\\(...\\)' (1-based) in REGEXP. The `\\(...\\)' groups are
+counted from 1.
`\\?' lets you edit the replacement text in the minibuffer
at the given position for each replacement.
For convenience, when entering TO-EXPR interactively, you can use `\\&' or
`\\0' to stand for whatever matched the whole of REGEXP, and `\\N' (where
-N is a digit) to stand for whatever matched the Nth `\\(...\\)' in REGEXP.
+N is a digit) to stand for whatever matched the Nth `\\(...\\)' (1-based)
+in REGEXP.
+
Use `\\#&' or `\\#N' if you want a number instead of a string.
In interactive use, `\\#' in itself stands for `replace-count'.
Fourth and fifth arg START and END specify the region to operate on.
-In TO-STRING, `\\&' stands for whatever matched the whole of REGEXP,
-and `\\=\\N' (where N is a digit) stands for
-whatever what matched the Nth `\\(...\\)' in REGEXP.
+In TO-STRING, `\\&' or `\\0' stands for whatever matched the whole of
+REGEXP, and `\\=\\N' (where N is a digit) stands for
+whatever matched the Nth `\\(...\\)' (1-based) in REGEXP.
`\\?' lets you edit the replacement text in the minibuffer
at the given position for each replacement.