[#bsl-basic_string-0e-replace-05] = xref:bsl.adoc[bsl]::xref:bsl/basic_string-0e.adoc[basic_string<wchar_t>]::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 + 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()`. == Synopsis Declared in `<bslstl_string.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<wchar_t>]& replace( xref:bsl/basic_string-0e/size_type.adoc[size_type] outPosition, xref:bsl/basic_string-0e/size_type.adoc[size_type] outNumChars, xref:bsl/basic_string-0faf.adoc[basic_string<wchar_t>] const& replacement, xref:bsl/basic_string-0e/size_type.adoc[size_type] position, xref:bsl/basic_string-0e/size_type.adoc[size_type] numChars = npos); ---- [.small]#Created with https://www.mrdocs.com[MrDocs]#