Navigation

Operators and Keywords

Function List:

C++ API

: newstr = strrep (str, ptn, rep)
: newstr = strrep (cellstr, ptn, rep)
: newstr = strrep (…, "overlaps", val)

Replace all occurrences of the pattern ptn in the string str with the string rep and return the result.

The optional argument "overlaps" determines whether the pattern can match at every position in str (true), or only for unique occurrences of the complete pattern (false). The default is true.

s may also be a cell array of strings, in which case the replacement is done for each element and a cell array is returned.

Example:

strrep ("This is a test string", "is", "&%$")
   ⇒  "Th&%$ &%$ a test string"

See also: regexprep, strfind, findstr.

Package: octave