[#bsl-basic_string-0ce-replace-0c]
= xref:bsl.adoc[bsl]::xref:bsl/basic_string-0ce.adoc[basic&lowbar;string&lt;char16&lowbar;t&gt;]::replace
:relfileprefix: ../../
:mrdocs:

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;

== Synopsis

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

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


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