(xemacs.info)Regexp Replace


Next: Replacement and Case Prev: Unconditional Replace Up: Replace
Enter node , (file) or (file)node

12.7.2 Regexp Replacement
-------------------------

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

   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
`cddr-safe'.

     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 version 1.2.2.9