[#BloombergLP-bdlb-StringRefUtil-substr] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/StringRefUtil.adoc[StringRefUtil]::substr :relfileprefix: ../../../ :mrdocs: Return a substring of `string` starting at `position`. == Synopsis Declared in `<bdlb_stringrefutil.h>` [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_type] position = 0, xref:BloombergLP/bdlb/StringRefUtil/size_type.adoc[size_type] numChars = k_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() ‐ position`, whichever is smaller. If `position` is not specified, 0 is used (i.e., the substring is from the beginning of this string). If `numChars` is not specified, `k_NPOS` is used (i.e., the entire suffix from `position` to the end of the string is returned). The behavior is undefined unless `position` is within the string boundaries (`0 <= position <= string.length()`). == Return Value substring of `string` starting at `position` == Parameters [cols="1,4"] |=== | Name| Description | *string* | string from which the substring is taken | *position* | starting index of the substring (0 if not specified) | *numChars* | maximum length of the substring (`k_NPOS` if not specified) |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#