- #1
TylerH
- 729
- 0
How do I require a character but not have it reported in a sub_match?
Specifically:
How do I get arbitrary to match all the additive terms of a mathematical expression, but keep the +s out of the sub_match-es?
BTW, I'm using Boost's regex, Perl syntax.
Thanks for reading.
Specifically:
Code:
void expression::add(expression &e, const expression &f)
{
regex arbitrary("(^|\\+)\\s*\\l+(\\((\\d+|\\l+)\\)|)\\s*(\\+|$)");
smatch matches;
std::string r, t;
t = e.e + f.e;
regex_search(t, matches, arbitrary);
for(auto match = matches.begin();match < matches.end();match++)
{
std::cout << *match << std::endl;
r += *match;
}
e.e = r;
}
BTW, I'm using Boost's regex, Perl syntax.
Thanks for reading.