[#BloombergLP-bdlb-StringViewUtil-substr]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/StringViewUtil.adoc[StringViewUtil]::substr
:relfileprefix: ../../../
:mrdocs:

Return a substring of `string` starting at `position`&period;

== Synopsis

Declared in `&lt;bdlb&lowbar;stringviewutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
std::string&lowbar;view
substr(
    std::string&lowbar;view const& string,
    xref:BloombergLP/bdlb/StringViewUtil/size_type.adoc[size&lowbar;type] position = 0,
    xref:BloombergLP/bdlb/StringViewUtil/size_type.adoc[size&lowbar;type] numChars = k&lowbar;NPOS);
----

== Description

Return a string whose value is the substring starting at the optionally specified `position` in the specified `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, `k&lowbar;NPOS` is used (i&period;e&period;, the entire suffix from `position` to the end of the string is returned)&period; The behavior is undefined unless `position` is within the string boundaries (`0 &lt;&equals; position &lt;&equals; string&period;length()`)&period;

== Return Value

substring of `string` starting at `position`

== Parameters

[cols="1,4"]
|===
| Name| Description
| *string*
| string view from which to take the substring
| *position*
| starting index of the substring (default 0)
| *numChars*
| maximum length of the substring (default `k&lowbar;NPOS`)
|===


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