This documentation is archived and is not being maintained.


Extracts characters from the string, starting with the first character, that are in the set of characters identified by pszCharSet.

CStringT SpanIncluding(
   PCXSTR pszCharSet
) const;


A string interpreted as a set of characters.

A substring that contains characters in the string that are in pszCharSet, beginning with the first character in the string and ending when a character is found in the string that is not in pszCharSet. SpanIncluding returns an empty substring if the first character in the string is not in the specified set.

If the first character of the string is not in the character set, then SpanIncluding returns an empty string. Otherwise, it returns a sequence of consecutive characters that are in the set.

// typedef CStringT<TCHAR, StrTraitATL<TCHAR, ChTraitsCRT<TCHAR>>> CAtlString;

CAtlString str(_T("cabbage"));
CAtlString res = str.SpanIncluding(_T("abc"));
ASSERT(res == _T("cabba"));
res = str.SpanIncluding(_T("xyz"));

Header: cstringt.h