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

Return a substring of this string as a const lvalue&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]
substr(
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] position = 0,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] numChars = npos) const &amp;;
----

== Description

Return a string whose value is the substring starting at the optionally specified `position` in this string, of length the optionally specified `numChars` or `length() &hyphen; position`, whichever is smaller&period; If `position` is not specified, 0 is used (i&period;e&period;, the substring is from the beginning of this string)&period; If `numChars` is not specified, `npos` is used (i&period;e&period;, the entire suffix from `position` to the end of the string is returned)&period;

== Return Value

substring of this string

== Parameters

[cols="1,4"]
|===
| Name| Description
| *position*
| starting index
| *numChars*
| number of characters
|===


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