[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
What's the doc of replace-regexp-in-string saying ?
From: |
bolega |
Subject: |
What's the doc of replace-regexp-in-string saying ? |
Date: |
Wed, 08 Dec 2010 15:37:01 -0000 |
User-agent: |
G2/1.0 |
Hello All,
In this doc, its not clear what the role of \' is ?
Can any kind soul give various examples of usage of this to match and
replace regexp with a given STRING , I repeat, in a STRING, not the
buffer.
Bolega
replace-regexp-in-string is a compiled Lisp function in `subr'.
(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.
Optional arguments FIXEDCASE, LITERAL and SUBEXP are like the
arguments with the same names of function `replace-match'. If START
is non-nil, start replacements at that index in STRING.
REP is either a string used as the NEWTEXT arg of `replace-match' or a
function. If it is a function it is applied to each match to generate
the replacement passed to `replace-match'; the match-data at this
point are such that match 0 is the function's argument.
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"
- What's the doc of replace-regexp-in-string saying ?,
bolega <=