#using <system.dll>
using namespace System;
using namespace System::Text::RegularExpressions;
int _tmain(int argc, _TCHAR* argv[])
{
//FindnFile("D:riss4uWebContent");
int words = 0;
String^ pattern = "[a-zA-Z]*";
Console::WriteLine( "pattern : '{0}'", pattern );
Regex^ regex = gcnew Regex( pattern );
String^ line = "onettwo three:four,five six seven";
Console::WriteLine( "text : '{0}'", line );
for( Match^ match = regex->Match( line );
match->Success; match = match->NextMatch( ) )
{
if( match->Value->Length > 0 )
{
words++;
Console::WriteLine( "{0}", match->Value );
}
}
Console::WriteLine( "Number of Words : {0}", words );
return 0;
}
공통언어런타임 지원을 설정해야 한다.(프로젝트 -> 속성 에서 설정)

댓글 달기