[#bsl-basic_string-01d-replace-08] = xref:bsl.adoc[bsl]::xref:bsl/basic_string-01d.adoc[basic_string<char8_t>]::replace :relfileprefix: ../../ :mrdocs: `replace` overloads == Synopses Declared in `<bslstl_string.h>` Replace the substring in the range starting at the specified `first` position and ending right before the specified `last` position with the specified `replacement` string. Return a reference providing modifiable access to this string. The behavior is undefined unless `first` and `last` are both within the range `[cbegin() .. cend()]` and `first <= last`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-0b.adoc[replace]( xref:bsl/basic_string-01d/const_iterator.adoc[const_iterator] first, xref:bsl/basic_string-01d/const_iterator.adoc[const_iterator] last, xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>] const& replacement); ---- [.small]#xref:bsl/basic_string-01d/replace-0b.adoc[_» more..._]# Replace the substring in the range starting at the specified `first` position and ending right before the specified `last` position with the specified null‐terminated `characterString` (of length `CHAR_TRAITS::length(characterString)`). Return a reference providing modifiable access to this string. The behavior is undefined unless `first` and `last` are both within the range `[cbegin() .. cend()]` and `first <= last`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-046.adoc[replace]( xref:bsl/basic_string-01d/const_iterator.adoc[const_iterator] first, xref:bsl/basic_string-01d/const_iterator.adoc[const_iterator] last, char8_t const* characterString); ---- [.small]#xref:bsl/basic_string-01d/replace-046.adoc[_» more..._]# Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition + outNumChars > length()`) with the specified `replacement` string, and return a reference providing modifiable access to this string. Throw `out_of_range` if `outPosition > length()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-068.adoc[replace]( xref:bsl/basic_string-01d/size_type.adoc[size_type] outPosition, xref:bsl/basic_string-01d/size_type.adoc[size_type] outNumChars, xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>] const& replacement); ---- [.small]#xref:bsl/basic_string-01d/replace-068.adoc[_» more..._]# Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition + outNumChars > length()`) with the specified null‐terminated `characterString` (of length `CHAR_TRAITS::length(characterString)`). Return a reference providing modifiable access to this string. Throw `out_of_range` if `outPosition > length()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-092.adoc[replace]( xref:bsl/basic_string-01d/size_type.adoc[size_type] outPosition, xref:bsl/basic_string-01d/size_type.adoc[size_type] outNumChars, char8_t const* characterString); ---- [.small]#xref:bsl/basic_string-01d/replace-092.adoc[_» more..._]# Replace the substring in the range starting at the specified `first` position and ending right before the specified `last` position with the specified `replacement`. Return a reference providing modifiable access to this string. The behavior is undefined unless `first` and `last` are both within the range `[cbegin() .. cend()]` and `first <= last`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class STRING_VIEW_LIKE_TYPE> xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-04e.adoc[replace]( xref:bsl/basic_string-01d/const_iterator.adoc[const_iterator] first, xref:bsl/basic_string-01d/const_iterator.adoc[const_iterator] last, STRING_VIEW_LIKE_TYPE const& replacement); ---- [.small]#xref:bsl/basic_string-01d/replace-04e.adoc[_» more..._]# Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition + outNumChars > length()`) with the specified `replacement`, and return a reference providing modifiable access to this string. Throw `out_of_range` if `outPosition > length()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class STRING_VIEW_LIKE_TYPE> xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-076.adoc[replace]( xref:bsl/basic_string-01d/size_type.adoc[size_type] outPosition, xref:bsl/basic_string-01d/size_type.adoc[size_type] outNumChars, STRING_VIEW_LIKE_TYPE const& replacement); ---- [.small]#xref:bsl/basic_string-01d/replace-076.adoc[_» more..._]# Replace the substring in the range starting at the specified `first` position and ending right before the specified `last` position with the specified `numChars` copies of the specified `character`. Return a reference providing modifiable access to this string. The behavior is undefined unless `first` and `last` are both within the range `[cbegin() .. cend()]` and `first <= last`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-0a2c.adoc[replace]( xref:bsl/basic_string-01d/const_iterator.adoc[const_iterator] first, xref:bsl/basic_string-01d/const_iterator.adoc[const_iterator] last, xref:bsl/basic_string-01d/size_type.adoc[size_type] numChars, char8_t character); ---- [.small]#xref:bsl/basic_string-01d/replace-0a2c.adoc[_» more..._]# Replace the substring in the range starting at the specified `first` position and ending right before the specified `last` position with the specified initial `numChars` characters in the specified `characterString`. Return a reference providing modifiable access to this string. The behavior is undefined unless `first` and `last` are both within the range `[cbegin() .. cend()]`, `first <= last`, and `characterString` is at least `numChars` long. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-0a20.adoc[replace]( xref:bsl/basic_string-01d/const_iterator.adoc[const_iterator] first, xref:bsl/basic_string-01d/const_iterator.adoc[const_iterator] last, char8_t const* characterString, xref:bsl/basic_string-01d/size_type.adoc[size_type] numChars); ---- [.small]#xref:bsl/basic_string-01d/replace-0a20.adoc[_» more..._]# Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition + outNumChars > length()`) with the specified `numChars` copies of the specified `character`. Return a reference providing modifiable access to this string. Throw `out_of_range` if `outPosition > length()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-09f.adoc[replace]( xref:bsl/basic_string-01d/size_type.adoc[size_type] outPosition, xref:bsl/basic_string-01d/size_type.adoc[size_type] outNumChars, xref:bsl/basic_string-01d/size_type.adoc[size_type] numChars, char8_t character); ---- [.small]#xref:bsl/basic_string-01d/replace-09f.adoc[_» more..._]# Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition + outNumChars > length()`) with the specified initial `numChars` characters in the specified `characterString`. Return a reference providing modifiable access to this string. Throw `out_of_range` if `outPosition > length()`. The behavior is undefined unless `characterString` is at least `numChars` long. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-01.adoc[replace]( xref:bsl/basic_string-01d/size_type.adoc[size_type] outPosition, xref:bsl/basic_string-01d/size_type.adoc[size_type] outNumChars, char8_t const* characterString, xref:bsl/basic_string-01d/size_type.adoc[size_type] numChars); ---- [.small]#xref:bsl/basic_string-01d/replace-01.adoc[_» more..._]# Replace the substring in the range starting at the specified `first` position and ending right before the specified `last` position with the characters in the range starting at the specified `stringFirst` and ending right before the specified `stringLast` iterator, both of the (template parameter) type `INPUT_ITER`. Return a reference providing modifiable access to this string. The behavior is undefined unless `first` and `last` are both within the range `[cbegin() .. cend()]`, `first <= last`, and `stringFirst` and `stringLast` refer to a sequence of valid values where `stringFirst` is at a position at or before `stringLast`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class INPUT_ITER> xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-070.adoc[replace]( xref:bsl/basic_string-01d/const_iterator.adoc[const_iterator] first, xref:bsl/basic_string-01d/const_iterator.adoc[const_iterator] last, INPUT_ITER stringFirst, INPUT_ITER stringLast); ---- [.small]#xref:bsl/basic_string-01d/replace-070.adoc[_» more..._]# Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition + outNumChars > length()`) with the optionally specified `numChars` characters starting at the specified `position` in the specified `replacement` string (or the suffix of `replacement` starting at `position` if `position + numChars > replacement.length()`). If `numChars` is not specified, `npos` is used. Return a reference providing modifiable access to this string. Throw `out_of_range` if `outPosition > length()` or `position > replacement.length()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-0c.adoc[replace]( xref:bsl/basic_string-01d/size_type.adoc[size_type] outPosition, xref:bsl/basic_string-01d/size_type.adoc[size_type] outNumChars, xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>] const& replacement, xref:bsl/basic_string-01d/size_type.adoc[size_type] position, xref:bsl/basic_string-01d/size_type.adoc[size_type] numChars = npos); ---- [.small]#xref:bsl/basic_string-01d/replace-0c.adoc[_» more..._]# Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition + outNumChars > length()`) with the optionally specified `numChars` characters starting at the specified `position` in the specified `replacement` (or the suffix of `replacement` starting at `position` if `position + numChars > replacement.length()`). If `numChars` is not specified, `npos` is used. Return a reference providing modifiable access to this string. Throw `out_of_range` if `outPosition > length()` or `position > replacement.length()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class STRING_VIEW_LIKE_TYPE> xref:bsl/basic_string-0faf.adoc[basic_string<char8_t>]& xref:bsl/basic_string-01d/replace-06a.adoc[replace]( xref:bsl/basic_string-01d/size_type.adoc[size_type] outPosition, xref:bsl/basic_string-01d/size_type.adoc[size_type] outNumChars, STRING_VIEW_LIKE_TYPE const& replacement, xref:bsl/basic_string-01d/size_type.adoc[size_type] position, xref:bsl/basic_string-01d/size_type.adoc[size_type] numChars = npos); ---- [.small]#xref:bsl/basic_string-01d/replace-06a.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#