Mercurial > emacs
changeset 28148:0f14966fe791
(replace-regexp-in-string): Renamed from
replace-regexps-in-string. Doc fix.
author | Dave Love <fx@gnu.org> |
---|---|
date | Tue, 14 Mar 2000 22:57:28 +0000 |
parents | 02f9ade0908d |
children | fd72698178e7 |
files | lisp/subr.el |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/subr.el Tue Mar 14 21:17:59 2000 +0000 +++ b/lisp/subr.el Tue Mar 14 22:57:28 2000 +0000 @@ -1196,8 +1196,8 @@ (aset newstr i tochar))) newstr)) -(defun replace-regexps-in-string (regexp rep string &optional - fixedcase literal subexp start) +(defun replace-regexp-in-string (regexp rep string &optional + fixedcase literal subexp start) "Replace all matches for REGEXP with REP in STRING. Return a new string containing the replacements. @@ -1211,7 +1211,11 @@ the replacement passed to `replace-match'; the match-data at this point are such that match 0 is the function's argument. -To replace a single match, make REGEXP match up to \\'." +To replace only the first match (if any), make REGEXP match up to \\' +and replace a sub-expression, e.g. + (replace-regexp-in-string \"\\(foo\\).*\\'\" \"bar\" \" foo foo\" nil nil 1) + => \" bar foo\" +" ;; To avoid excessive consing from multiple matches in long strings, ;; don't just call `replace-match' continually. Walk down the