How would I split a string based on another substring in a simple way?
e.g. split on \"\\r\\n\"
message1\\r\\nmessage2
=>
As long as it concerns whitespace:
string s("somethin\nsomethingElse");
strinstream ss(s);
string line;
vector lines;
while( ss >> line )
{
lines.push_back( line );
}
Alternatively, use getline(), which allows you to specify the tokenizing character as an optional third parameter:
string s("Something\n\rOr\n\rOther");
stringstream ss(s);
vector lines;
string line;
while( getline(ss,line) )
{
lines.push_back(line);
}