SpanIncluding simple understanding is to extract a substring contained in a specified string
The note on MSDN says: Look for characters equal to the given string starting with the first character on the left, and if not, return an empty string, and vice versa, continue to find, to the end.
Easy to understand examples
CString str;
CString strdigital ("0123456");
str = "51920";
CString strval = str. SpanIncluding (strdigital);
MessageBox (Strval);
Strval= "51"
Extract the string in str with strdigtal to wait, starting from the first ' 5 ' to find,...., until a character in Str cannot be found in strdigtal ..., in the example, the ' 9 ' condition does not match, return directly to "51"
SpanExcluding and SpanIncluding just the opposite, and find a mismatch with the
CString str;
CString strdigital ("0123456");
str = "9867578";
CString strval = str. SpanExcluding (strdigital);
MessageBox (Strval);
Strval= "98"
No match found to ' 6 ', return ' 98 '
Judging whether a string is all numbers, you can write this
BOOL isdigital (CString str)
{
Return STR==STR. SpanIncluding ("0123456789");
}
The usage of spanincluding and spanexcluding in CString