help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[2nd attempt] What's the doc of replace-regexp-in-string saying ?


From: bolega
Subject: [2nd attempt] What's the doc of replace-regexp-in-string saying ?
Date: Wed, 08 Dec 2010 15:37:07 -0000
User-agent: G2/1.0

Hello All,

I am posting my question a second time. first time around, it was the
victim of the humor of come cynics.

Bolega

On Nov 21, 3:27 pm, bolega <gnuist...@gmail.com> wrote:
> 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"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]