(lemacs.info)Regexp Replace

Next: Replacement and Case Prev: Unconditional Replace Up: Replace

Regexp Replacement

   `replace-string' replaces exact matches for a single string.  The
similar command `replace-regexp' replaces any match for a specified

   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 text being replaced.  `\D' in
NEWSTRING, where D is a digit, stands for whatever matched the D'th
parenthesized grouping in REGEXP.  For example,

     M-x replace-regexp RET c[ad]+r RET \&-safe RET

would replace (for example) `cadr' with `cadr-safe' and `cddr' with

     M-x replace-regexp RET \(c[ad]+r\)-safe RET \1 RET

would perform exactly the opposite replacements.  To include a `\' in
the text to replace with, you must give `\\'.

automatically generated by info2www