IDLE 1.1.4
>>> import re
>>> some_text = 'alpha, beta,,,,gamma delta'
>>> re.split('[, ]+', some_text)
['alpha', 'beta', 'gamma', 'delta']
# when the pattern doesn't contain parentheses, the returned values
# only include matched substrings but separators.
>>> re.split('([, ]+)', some_text)
['alpha', ', ', 'beta', ',,,,', 'gamma', ' ', 'delta']
# returned values include separators and I can guess how it works.
>>> re.split('([, ])+', some_text)
['alpha', ' ', 'beta', ',', 'gamma', ' ', 'delta']
# Now I cannot even guess what is going on here.
Question> What is the difference between '([, ]+)' and '([, ])+'?
How it affects the returned values?
([, ]+)says “match one or more commas and/or spaces and capture them as a group”, thus in your second example your see the whole string of separator characaters returned in one group.([, ])+says “match one comma or space, and capture one or more groups of these”. So in your third example, each separator character is captured in it’s own group, and you’re only getting the last of these each time.