2.2.3.15.36 string::SpanExcluding

Description

Search the string for the first occurrence of any character in the specified set lpszCharSet.

Syntax

string SpanExcluding( LPCSTR lpszCharSet )

Parameters

lpszCharSet
[input]A string interpreted as a set of characters.

Return

A substring that contains characters in the string that are not in lpszCharSet, starting with the first character in the string and up to but excluding the first character in the string that is found lpszCharSet. It returns the entire string if no character in lpszCharSet is found in the string.

Examples

EX1

void string_SpanExcluding_ex1()
{
    string str1("Hello World! Goodbye!");
    string str2=str1.SpanExcluding(".!?");
    printf("the string left is \"%s\"\n", str2);
    //Should print"Hello World" since the substring after'!' is excluded   
    
    string str3("Hello World Goodbye");
    string str4=str3.SpanExcluding(".!?");
    printf("the string left is \"%s\"\n", str4);
    //Should print"Hello World Goodbye" since no specified characters (".!?") found in str2
}

Remark

This member function searches the string for the first occurrence of any character in the specified set lpszCharSet. SpanExcluding extracts and returns all characters preceding the first occurrence of a character from lpszCharSet(in other words, the character from lpszCharSet and all characters following it in the string, are not returned). If no character from lpszCharSet is found in the string, then SpanExcluding returns the entire string.

See Also

string::SpanIncluding

Header to Include

origin.h