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.

Return Value

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.


The following example demonstrates the use of CStringT::SpanIncluding.

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

CAtlString str( "cabbage" );
CAtlString res = str.SpanIncluding( "abc" );
_ASSERT( res == "cabba" );
res = str.SpanIncluding( "xyz" );
_ASSERT( res.IsEmpty( ) );

See Also

CStringT Overview | Class Members