0

regular expression like this:

import re
p = re.match(r'([abc])+','abc')
p.group()
'abc'
p.groups()
('c',)

I am confused about the result of p.groups(). In my opinion, this regular expression may equal to r'(a)(b)(c)', thus the result of p.groups() may be ('a','b','c'). But it seems like that this expression equals to r'ab(c)', in which the result of p.groups() is ('c',). But why!? How can I understand r'([abc])+'? Help me please.

Moooood
  • 21
  • 3
  • [Here](https://stackoverflow.com/questions/17393683/regex-only-capturing-last-instance-of-capture-group-in-match)'s a duplicate, but in JavaScript and with a disgusting regex. I'll try to find better. – Aaron Jul 24 '17 at 16:13
  • There are other dupes, even for Python – Wiktor Stribiżew Jul 24 '17 at 16:14

0 Answers0