I want to extract the key phrases from the document: "something KEY phrase END something ... ect". My rule works well but the result does not contain of key name. What should be the rule in order to get a string: "KEY phrase". Thank you for the advice.
std::vector<std::string> doc;
bool r = qi::phrase_parse(first,last,
( qi::omit[*(qi::char_-"KEY")]
>> qi::lexeme[ "KEY"
>> *(qi::char_-"KEY" -"END")] ) % "END"
, qi::space, doc);
qi::lit(...)
doesn't synthesize an attribute.qi::string(...)
does.Replace
"KEY"
with qi::string("KEY"), likely. (hard to tell without knowing the type ofdoc
)BONUS See also
seek[]
parser directive from the Spirit Repository:Here's what I'd do:
Live On Coliru
Prints:
Sample data included in a comment in this answer: /here/
Final benchmark:
Data size: 23.9 MB text file