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

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;

== Synopsis

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

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


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