I am learning Python regex, the following works as I expected:
>>> import re
>>> re.split('\s+|:', 'find a str:s2')
['find', 'a', 'str', 's2']
But when I change +to *, the conclusion is strange to me:
>>> re.split('\s*|:', 'find a str:s2')
['find', 'a', 'str:s2']
How is such a pattern interpreted in Python?
source
share