Visual C++의 .NET 프로그래밍

How to: Parse Strings Using the Split Method (C++/CLI)


Example


// regex_split.cpp

// compile with: /clr

using namespace System;


int main(array<System::String ^> ^args)

//가능함. int main()

{

   String^ delimStr = " ,.:\t";

   Console::WriteLine( "delimiter : '{0}'", delimStr );

   array<Char>^ delimiter = delimStr->ToCharArray( );

   array<String^>^ words;

   String^ line = "one\ttwo three:four,five six seven";


   Console::WriteLine( "text : '{0}'", line );

   words = line->Split( delimiter );

   Console::WriteLine( "Number of Words : {0}", words->Length );

   for (int word=0; word<words->Length; word++)

      Console::WriteLine( "{0}", words[word] );


   return 0;

}

결과

delimiter : ' ,.:       '

text : 'one     two three:four,five six seven'

Number of Words : 7

one

two

three

four

five

six

seven



Posted by 세모아
,