Problem to parse words from a text file that contains pipe as delimiter
I have a file that have values like
============================================================
Id | Name | Age |D | Type |P |
| | |O | |H |
| | |B | |Number |
============================================================
I have to parse these lines and extract the column names which are Id,Name,Age,DOB,Type,PHNumber into a vector.
I am not able to get DOB and PHNumber names.
Please suggest how should I parse these lines.
What I have tried:
boost::regex col_check("^[A-Z].*");
while(getline(ifile,record))
{
if(regex_match(record,col_check) )
{
string tmp=record;
istringstream line(tmp);
while(getline(line,token,'|'))
{
rows.push_back(token);
}
}
}