// Separate strings
// Compilation method: g -o reg_split -lboost-regex-gcc reg_split.cpp
#include
#include
Unsigned tokenise (std :: list
{
Return Boost :: Regex_Split (std :: back_inserter (l), s);
}
#include
Using namespace std;
#if defined (boost_msvc) || (Defined (__ borlandc__) && (__borlandc__ == 0x550))
//
// problem with std :: getline under msvc6sp3
iStream & getLine (istream & is, std :: string & s)
{
S.RASE ();
CHAR C = is.get ();
While (c! = '/ n')
{
S.Append (1, c);
C = is.get ();
}
Return IS;
}
#ENDIF
Int main (int Argc)
{
String S;
List
Do {
IF (argc == 1)
{
Cout << "Enter text to split (or /" quit / "to exit):";
GetLine (CIN, S);
IF (s == "quit") BREAK;
}
Else
S = "this is a string of tokens";
Unsigned result = tokenise (l, s);
Cout << Result << "tokens found" << endl;
Cout << "The remaining text is: /" << "<< S <<" / "<< end1
While (l.size ())
{
s = * (l.begin ());
L.POP_FRONT ();
Cout << s << endl;
}
} while (argc == 1);
Return 0;
}