#include <iostream>
#include <vector>
#include <string>
#include <boost/algorithm/string.hpp>
using namespace std;
int main()
{
// String to split
string str = "You're supposed to see this!|NOT THIS!!!!!!";
// Line container
vector<string> lines;
// Splits string
boost::split(lines, str, boost::is_any_of("|"), boost::token_compress_on);
// Outputs 1 half of the split string
cout << lines.at(0).c_str() << endl;
// Waits for input before program exits
cin.get();
return 0;
}
The following is the program in psuedocode:
Declare string str and set it to "You're supposed to see this!|NOT THIS!!!!!!".
Declare vector lines of type string.
Split string str into vector lines if regex "|" is found.
Print object at index 0 in lines.
Get input.