I have an input file that I want to tokenize. the text is like this:
MATERIAL "A992Fy50" TYPE "Steel" GRADE "Grade 50" WEIGHTPERVOLUME 0.007849048
The tricky part is to get the "Grade 50" as a single word. could any one suggest a regular expression in c++. I know how to do it without the white space inside the quote with:
const std::string text{"MATERIAL \"A992Fy50\" TYPE \"Steel\" GRADE \"Grade 50\" WEIGHTPERVOLUME 0.007849048"};
const std::regex ws_re{"\(\")?(\\s+)\(\")?"}; // whitespace
std::copy( std::sregex_token_iterator(text.begin(), text.end(), ws_re, -1),
std::sregex_token_iterator(),
std::ostream_iterator<std::string>(std::cout, "\n"));
but this also splits "Grade 50" to Grade and 50.