[#bsl-basic_string-0faf-replace-039]
= xref:bsl.adoc[bsl]::xref:bsl/basic_string-0faf.adoc[basic&lowbar;string]::replace
:relfileprefix: ../../
:mrdocs:

Replace a substring of this string&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]&
replace(
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] outPosition,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] outNumChars,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] numChars,
    CHAR&lowbar;TYPE character);
----

== Description

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;

== Return Value

reference providing modifiable access to this string

== Parameters

[cols="1,4"]
|===
| Name| Description
| *outPosition*
| index at which replacement begins
| *outNumChars*
| number of characters to replace
| *numChars*
| number of characters
| *character*
| character value
|===


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