※요약

SpanIncluding : 필요한 문자들만 추출한다.

SpanExcluding : 필요없는 문자들을 걸러낸다.



※특징

SpanIncluding()는 필요한 문자들만 추출할 때 편리하며,

SpanExcluding()는 필요없는 문자들을 걸러낼 때 편리하다.



※함수 원형 및 설명

CString SpanIncluding( LPCTSTR lpszCharSet ) const;
//lpszCharSet : NULL로 종결되는 문자셋
//반환값 : 추출된 문자열을 포함하는 CString 개체.

CString SpanExcluding( LPCTSTR lpszCharSet ) const;
//lpszCharSet : NULL로 종결되는 문자셋
//반환값 : 추출된 문자열을 포함하는 CString 개체.



※예제

#include <atlstr.h>		//CString

#define print(str) printf( "%s \n", str )

int main( )
{
	CString strText = "age is 19 ~*^^*";
	CString spnstr;
	
	//소문자 a ~ z 그리고 공백 문자가 포함된 문자열까지 추출합니다.
	spnstr = strText.SpanIncluding( "abcdefghijklmnopqrstuvwxyz " );
	print( strText );
	print( spnstr );

	//"~!@#$%^&*()-=_+[]{},.<>/?;:'`" 를 포함하지 않는 문자열까지 추출합니다.
	spnstr = strText.SpanExcluding( "~!@#$%^&*()-=_+[]{},.<>/?;:'`" );
	print( strText );
	print( spnstr );

	return 0;
}


+ Recent posts