Tuesday, 20 August 2013

How to get original string prefix in boost regex_search

How to get original string prefix in boost regex_search

I am using regex_search in boost like this:
std::string symbol = "abcd1234";
boost::regex regExpr("(\\d{4})", boost::regex::icase);
boost::smatch regMatch;
boost::regex_search(symbol, regMatch, regExpr);
What I need to get is: "abcd", i.e. the original string up to the first
matched reg expression. How is this possible? thanks in advance...

No comments:

Post a Comment