Next: , Previous: , Up: Replacing Text Using Match Data   [Index]


8.4.4.3 replace-regexp-in-string

Function: replace-regexp-in-string regexp rep string &optional fixedcase literal subexp start

This function uses replace-match to do the replacement.

REGEXP

the regexp to use

REP

replacement string or function.

If a function, replace-regexp-in-string calls REP for each match, passing the text of the match as its sole argument. It collects the value REP returns and passes that to replace-match as the replacement string.

STRING

string to search; this function copies STRING and searches it for matches for REGEXP, and replaces them with REP.

FIXEDCASE

passed to replace-match

LITERAL

passed to replace-match

SUBEXP

passed to replace-match

START

If START is non-‘nil’, the search for matches starts at that index in STRING, so matches starting before that index are not changed.

RETURN VALUE

It returns the modified copy.