CString strVal = str.SpanIncluding(strDigital); MessageBox(strVal); //strVal="51" 在str中提取与strDigtal想等的串,从第一个'5’开始查找,....,直到str中的一个字符在strDigtal找不到...,例子中,'9'条件不符,直接返回"51" SpanExcluding 与SpanInc
使用CString::SpanIncluding可以检验字符串的合法性,是否是我们要求的字符,比如全是数字构成的字符串,我们可以用下面的代码进行判断: [cpp]view plaincopy CString strTarget; ... if ( strTarget == strTarget.SpanIncluding( _T("0123456789") ) ) { // 字符串由数字构成,符合要求 } 或者[cpp]view plaincopy...
CStringSpanExcluding(LPCTSTRlpszCharSet**)const;** throw(CMemoryException); Return Value A substring that contains characters in the string that are not inlpszCharSet, beginning with the first character in the string and ending with the first character found in the string that is also inlpszCha...
cout<<csStr.ReverseFind('a'); //3 4、CString SpanExcluding( LPCTSTR lpszCharSet ) const; 返回与lpszCharSet中任意字符匹配的字符之前的子串(找到第一个匹配的字符就返回) 例:csStr="abcdef"; cout<<csStr.SpanExcluding("cf"); //ab CString SpanIncluding( LPCTSTR lpszCharSet ) const; 查找与lpsz...
SpanExcluding 提取一个字符串,该子字符串中不含有某一字符集合中的字符。 其他转换 MakeUpper 将字符串中的所有字符转换为大写字符 MakeLower 将字符串中的所有字符转换为小写字符 MakeReverse 将字符串中的字符以倒序排列 Replace 用其它字符替换指定的字符 Remove 从一个字符串中移走指定的字符 Insert 在字符串中...
12.CString SpanExcluding( LPCTSTR lpszCharSet ) const;throw( CMemoryException ); 说明:从字符串中提取不包含在指定字符集lpszCharSet中的字符的子串。 13.MakeUpper 将字符串中所有的字符全部转化成大写形式。 14.MakeLower 将字符串中所有的字符全部转化成小写形式。
CString位于头文件afx.h中。 CString 的 成员函数 CString的构造函数 CString( ); 例:CString csStr; CString( const CString& stringSrc ); 例:CString csStr("ABCDEF中文123456"); CString csStr2(csStr); CString( TCHAR ch, int nRepeat = 1 ); ...
//当nStart为负数时,返回-1。 int FindOneOf( LPCTSTR lpszCharSet ) const; 查找lpszCharSet中任意一个字符在CString对象中的匹配位置。未找到时返回-1,否则返回字串的开始位置 例:csStr="abcdef"; cout<<csStr.FindOneOf("cxy");//2 CString SpanExcluding( LPCTSTR lpszCharSet ) const; ...
// example for CString::SpanIncluding CString str( "cabbage" ); CString res = str.SpanIncluding( "abc" ); ASSERT( res == "cabba" ); res = str.SpanIncluding( "xyz" ); ASSERT( res.IsEmpty( ) ); CString Overview | Class Members | Hierarchy Chart See Also CString::SpanExcludingEnglish...
CString SpanExcluding( LPCTSTR lpszCharSet ) const; 它查找CString对象中与lpszCharSet串中任意匹配的第一个字符,并返回一个CString对象,该对象的内容是原来对象从起始位置到查找到字符的前一个字符的部分。这在分离用分割符(逗号空格之类)隔开的子串的时候将十分方便: ...