Skip to content

strrep

builtin · libnexusinterp/corefcn/strfind-proprietary.cc

: s = strrep (str, pat, rep)
: s = strrep (str, pat, rep, "overlaps", tf)

Substitute every occurrence of pat within str with rep.

By default, and whenever "overlaps" is set to false, the scan continues past the whole of each replaced region, so text that formed a match is not examined again. Setting "overlaps" to true advances only a single character after each match, which lets a subsequent match begin inside the text of the previous one. An empty pat leaves str untouched.

When str is a cell array of strings each element is processed on its own and s is a cell array of the results.