Increase the regex. Named group in two parts

I have a problem with boost::regex::regex_match. I work with it 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 works fine)

((?<group>[0-6])[ ]?)*

output1: what["group"]=5andwhat["group"].captures()= [3, 4, 5]

output2: not matched

The problem is this:

I need to collect data from more than one part of a regular expression into one group.

I tried:

((?<group>[0-6])[ ])*(?<group>[0-6])

output1: what["group"]=4andwhat["group"].captures()=[3, 4]

output2: not matched

OK, I understand. He does not see the second announcement of the group.

I tried:

((?<group>[0-6])[ ])*(?&group)

output1: what["group"]=4andwhat["group"].captures()= [3, 4, 4]

output2: not matched

  • But what is it? Where is the second 4 of? He checks the “group” pattern because the first example matches, and the second does not. But it doubles the last found value instead of saving the new one. What for? Maybe I forgot to turn on the flags?
  • ?

, token_iterator .

. Xpressive .

+5
1

:

String Total price: $1,234

1234 ( )

, . 2 lookaheads, . , , (.. 1 5000), -

Total price: \$(?P<price>\d{1,3})(?:(?=\,),(?P<price2>\d{3})|)

1-3 , , , .

: www.regex101.com

0

All Articles