Function: s-replace-regexp

s-replace-regexp is a for replace-regexp-in-string, defined in subr.el.gz.

Signature

(s-replace-regexp REGEXP REP STRING &optional FIXEDCASE LITERAL SUBEXP START)

Documentation

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, and omit the first START characters of STRING from the return value.

REP is either a string used as the NEWTEXT arg of replace-match or a function. If it is a function, it is called with the actual text of each match, and its value is used as the replacement text. When REP is called, the match data are the result of matching REGEXP against a substring of STRING, the same substring that is the actual text of the match which is passed to REP as its 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"

Aliases

mh-replace-regexp-in-string s-replace-regexp icalendar--rris (obsolete since 27.1) erc-replace-regexp-in-string (obsolete since 28.1)