[#bsl-basic_string-01d-replace-08]
= xref:bsl.adoc[bsl]::xref:bsl/basic_string-01d.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]::replace
:relfileprefix: ../../
:mrdocs:

`replace` overloads

== Synopses

Declared in `&lt;bslstl&lowbar;string&period;h&gt;`

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&period; Return a reference providing modifiable access to this string&period; The behavior is undefined unless `first` and `last` are both within the range `&lsqb;cbegin() &period;&period; cend()&rsqb;` and `first &lt;&equals; last`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-0b.adoc[replace](
    xref:bsl/basic_string-01d/const_iterator.adoc[const&lowbar;iterator] first,
    xref:bsl/basic_string-01d/const_iterator.adoc[const&lowbar;iterator] last,
    xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;] const& replacement);
----

[.small]#xref:bsl/basic_string-01d/replace-0b.adoc[_» more&period;&period;&period;_]#

Replace the substring in the range starting at the specified `first` position and ending right before the specified `last` position with the specified null&hyphen;terminated `characterString` (of length `CHAR&lowbar;TRAITS&colon;&colon;length(characterString)`)&period; Return a reference providing modifiable access to this string&period; The behavior is undefined unless `first` and `last` are both within the range `&lsqb;cbegin() &period;&period; cend()&rsqb;` and `first &lt;&equals; last`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-046.adoc[replace](
    xref:bsl/basic_string-01d/const_iterator.adoc[const&lowbar;iterator] first,
    xref:bsl/basic_string-01d/const_iterator.adoc[const&lowbar;iterator] last,
    char8&lowbar;t const* characterString);
----

[.small]#xref:bsl/basic_string-01d/replace-046.adoc[_» more&period;&period;&period;_]#

Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition &plus; outNumChars &gt; length()`) with the specified `replacement` string, and return a reference providing modifiable access to this string&period; Throw `out&lowbar;of&lowbar;range` if `outPosition &gt; length()`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-068.adoc[replace](
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outPosition,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outNumChars,
    xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;] const& replacement);
----

[.small]#xref:bsl/basic_string-01d/replace-068.adoc[_» more&period;&period;&period;_]#

Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition &plus; outNumChars &gt; length()`) with the specified null&hyphen;terminated `characterString` (of length `CHAR&lowbar;TRAITS&colon;&colon;length(characterString)`)&period; Return a reference providing modifiable access to this string&period; Throw `out&lowbar;of&lowbar;range` if `outPosition &gt; length()`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-092.adoc[replace](
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outPosition,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outNumChars,
    char8&lowbar;t const* characterString);
----

[.small]#xref:bsl/basic_string-01d/replace-092.adoc[_» more&period;&period;&period;_]#

Replace the substring in the range starting at the specified `first` position and ending right before the specified `last` position with the specified `replacement`&period; Return a reference providing modifiable access to this string&period; The behavior is undefined unless `first` and `last` are both within the range `&lsqb;cbegin() &period;&period; cend()&rsqb;` and `first &lt;&equals; last`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE&gt;
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-04e.adoc[replace](
    xref:bsl/basic_string-01d/const_iterator.adoc[const&lowbar;iterator] first,
    xref:bsl/basic_string-01d/const_iterator.adoc[const&lowbar;iterator] last,
    STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE const& replacement);
----

[.small]#xref:bsl/basic_string-01d/replace-04e.adoc[_» more&period;&period;&period;_]#

Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition &plus; outNumChars &gt; length()`) with the specified `replacement`, and return a reference providing modifiable access to this string&period; Throw `out&lowbar;of&lowbar;range` if `outPosition &gt; length()`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE&gt;
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-076.adoc[replace](
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outPosition,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outNumChars,
    STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE const& replacement);
----

[.small]#xref:bsl/basic_string-01d/replace-076.adoc[_» more&period;&period;&period;_]#

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`&period; Return a reference providing modifiable access to this string&period; The behavior is undefined unless `first` and `last` are both within the range `&lsqb;cbegin() &period;&period; cend()&rsqb;` and `first &lt;&equals; last`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-0a2c.adoc[replace](
    xref:bsl/basic_string-01d/const_iterator.adoc[const&lowbar;iterator] first,
    xref:bsl/basic_string-01d/const_iterator.adoc[const&lowbar;iterator] last,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] numChars,
    char8&lowbar;t character);
----

[.small]#xref:bsl/basic_string-01d/replace-0a2c.adoc[_» more&period;&period;&period;_]#

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`&period; Return a reference providing modifiable access to this string&period; The behavior is undefined unless `first` and `last` are both within the range `&lsqb;cbegin() &period;&period; cend()&rsqb;`, `first &lt;&equals; last`, and `characterString` is at least `numChars` long&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-0a20.adoc[replace](
    xref:bsl/basic_string-01d/const_iterator.adoc[const&lowbar;iterator] first,
    xref:bsl/basic_string-01d/const_iterator.adoc[const&lowbar;iterator] last,
    char8&lowbar;t const* characterString,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] numChars);
----

[.small]#xref:bsl/basic_string-01d/replace-0a20.adoc[_» more&period;&period;&period;_]#

Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition &plus; outNumChars &gt; length()`) with the specified `numChars` copies of the specified `character`&period; Return a reference providing modifiable access to this string&period; Throw `out&lowbar;of&lowbar;range` if `outPosition &gt; length()`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-09f.adoc[replace](
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outPosition,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outNumChars,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] numChars,
    char8&lowbar;t character);
----

[.small]#xref:bsl/basic_string-01d/replace-09f.adoc[_» more&period;&period;&period;_]#

Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition &plus; outNumChars &gt; length()`) with the specified initial `numChars` characters in the specified `characterString`&period; Return a reference providing modifiable access to this string&period; Throw `out&lowbar;of&lowbar;range` if `outPosition &gt; length()`&period; The behavior is undefined unless `characterString` is at least `numChars` long&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-01.adoc[replace](
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outPosition,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outNumChars,
    char8&lowbar;t const* characterString,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] numChars);
----

[.small]#xref:bsl/basic_string-01d/replace-01.adoc[_» more&period;&period;&period;_]#

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&lowbar;ITER`&period; Return a reference providing modifiable access to this string&period; The behavior is undefined unless `first` and `last` are both within the range `&lsqb;cbegin() &period;&period; cend()&rsqb;`, `first &lt;&equals; last`, and `stringFirst` and `stringLast` refer to a sequence of valid values where `stringFirst` is at a position at or before `stringLast`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class INPUT&lowbar;ITER&gt;
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-070.adoc[replace](
    xref:bsl/basic_string-01d/const_iterator.adoc[const&lowbar;iterator] first,
    xref:bsl/basic_string-01d/const_iterator.adoc[const&lowbar;iterator] last,
    INPUT&lowbar;ITER stringFirst,
    INPUT&lowbar;ITER stringLast);
----

[.small]#xref:bsl/basic_string-01d/replace-070.adoc[_» more&period;&period;&period;_]#

Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition &plus; outNumChars &gt; 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 &plus; numChars &gt; replacement&period;length()`)&period; If `numChars` is not specified, `npos` is used&period; Return a reference providing modifiable access to this string&period; Throw `out&lowbar;of&lowbar;range` if `outPosition &gt; length()` or `position &gt; replacement&period;length()`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-0c.adoc[replace](
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outPosition,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outNumChars,
    xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;] const& replacement,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] position,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] numChars = npos);
----

[.small]#xref:bsl/basic_string-01d/replace-0c.adoc[_» more&period;&period;&period;_]#

Replace the specified `outNumChars` characters starting at the specified `outPosition` in this string (or the suffix of this string starting at `outPosition` if `outPosition &plus; outNumChars &gt; 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 &plus; numChars &gt; replacement&period;length()`)&period; If `numChars` is not specified, `npos` is used&period; Return a reference providing modifiable access to this string&period; Throw `out&lowbar;of&lowbar;range` if `outPosition &gt; length()` or `position &gt; replacement&period;length()`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE&gt;
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
xref:bsl/basic_string-01d/replace-06a.adoc[replace](
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outPosition,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] outNumChars,
    STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE const& replacement,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] position,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] numChars = npos);
----

[.small]#xref:bsl/basic_string-01d/replace-06a.adoc[_» more&period;&period;&period;_]#


[.small]#Created with https://www.mrdocs.com[MrDocs]#
