How to judge matched rule when looping with sregex_token_iterator in boost.xpressive?

3 Jul
2014
3 Jul
'14
3:47 a.m.
Dear all, I would like to use boost.xpressive to parse some string like “a+b:c”, and I wrote the following snippet: sregex reOp = as_xpr('+') | '-' | '*' | '/'; sregex reDelim = as_xpr(':'); sregex reField = +_w; sregex reSimpleToken = reOp | reDelim | reField; string str = "a+b:c"; sregex_token_iterator cur(str.begin(), str.end(), reSimpleToken), end; for (; cur != end; ++cur) { cout << *cur << endl; } which will print: a + b : c but I would also want to know which rule is matched for the sequent operations, for example ‘a’, ‘b’ and ‘c' are matched by reField, and ‘+’ is matched by ‘reOp’. I am very new to boost.xpressive, so if this is not the good way, correct me please. Any help is appreciated! Best, Li
4019
Age (days ago)
4019
Last active (days ago)
16 comments
7 participants
participants (7)
-
Li Dong