Makes a copy of the target sequence (the subject) with all matches of the regular expression rgx (the pattern) replaced by fmt (the replacement). The target sequence is either s or the character sequence between first and last, depending on the version used. The resulting sequence is returned as a string object on versions 1, 2, 3 and 4. Versions 5 and 6 take an output iterator as first argument, which is used to store the resulting sequence. An optional parameter, flags, allows to specify options on how to match and format the expression.