# why two tuple
Group # not capture execution order how to calculate?
CodePudding user response:
If there a parenthesis matching rules:
Re. The.findall (' (ab) ', 'abab)
Returns the parentheses are matching to the result of matching to the two ab, the output is [' ab ', 'ab']
Outside the parentheses to nested parentheses:
Re. The.findall (' ((ab)) ', 'abab)
Match again once, and the results of several single match to the bracket, there are a few tuples, the number of elements in the tuple is the number of matching,
CodePudding user response:
The '(((ab)))', 'abab'CodePudding user response:
[(' ab ', 'ab', 'ab', 'ab', 'ab'), (' ab ', 'ab', 'ab', 'ab', 'ab')] why there is so muchCodePudding user response:
You set up private chat with strangers, cannot reply,From the inside out, the first matching result is list [ab, ac, AD, ae, af], the second is [(ab, ab),] (ac, ac)... ,
Is equal to the value to the first match results,
Match several times (a few braces), how many elements within tuples,
Print (re. The.findall (' (((ab))) ', 'abab))
[(' ab ', 'ab', 'ab'), (' ab ', 'ab', 'ab')]