What would be the result of len(match.groups()) of a match of (a)(b(?:c)(d)(?:e))? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What would be the result of len(match.groups()) of a match of (a)(b(?:c)(d)(?:e))?

help me

9th Jun 2017, 9:41 AM
R.kishore
R.kishore - avatar
2 Answers
+ 2
There are 5 parentheses in the example, which means 5 groups. However, two of them are marked with '?:', which means that they are non-capturing (not counted in the result) - so the final answer is 5-2 = 3 groups.
9th Jun 2017, 9:48 AM
Bogdan Sass
Bogdan Sass - avatar
+ 1
3
4th Jan 2021, 2:01 PM
Oumar TOURE
Oumar TOURE - avatar