I have problem with boost::regex::regex_match
. I work with turned on BOOST_REGEX_MATCH_EXTRA
.
What I have:
(this is a simple example of my problem, not a real task)
string input1= "3 4 5";
string input2= "3 4 7";
What I want to get:
list output1= [3 4 5];
list output2= []; //not matched
regex:
(this is working ok)
((?<group>[0-6])[ ]?)*
output1: what["group"]=5
and what["group"].captures()= [3, 4, 5]
output2: not matched
The problem is:
I need to collect data from more then one part of regex to one group.
I tried:
((?<group>[0-6])[ ])*(?<group>[0-6])
output1: what["group"]=4
and what["group"].captures()=[3, 4]
output2: not matched
OK, I understand. It doesn't see second declaration of group.
I tried:
((?<group>[0-6])[ ])*(?&group)
output1: what["group"]=4
and what["group"].captures()= [3, 4, 4]
output2: not matched
- But What THIS? Where is the second 4 from? It checks "group" pattern, because the first example matches, but the second doesn't. But it doubles last found value instead of saving new. Why? Maybe I forgot to turn on some flags?
- And is there another way to get in one group data from different part of regex expression?
I have more then one group, so token_iterator can't help me.
And expression should be configured in config file. static Xpressive can't be used.