capture-group

Why won't re.groups() give me anything for my one correctly-matched group?

Why won't re.groups() give me anything for my one correctly-matched group? Question: When I run this code: print re.search(r’1′, ‘1’).groups() I get a result of (). However, .group(0) gives me the match. Shouldn’t groups() give me something containing the match? Asked By: dtc || Source Answers: groups is empty since you do not have any …

Total answers: 4