I am learning regular expression in Python and I am having trouble understanding a function groups().
>>> m = re.match("([abc])+", "abc")
Here I defined the class [abc], which, as I know, means any of the characters from a to c. It is defined within the group, and the + sign means that we want at least one of these groups. So I execute the following line, and the result is clear:
>>> m.group()
'abc'
>>> m.group(0)
'abc'
I understand why this is happening. The index of the main group is 0, and "abc" corresponds to the class that we defined. So far, so good, but I don’t understand why the following lines are executed the way they do:
>>> m.group(1)
'c'
>>> m.groups()
('c',)
(1), "c"? , ? , "abc".