I wanted to cut a string of email addresses that can be separated by any combination of commas and spaces.
And I thought it would be pretty straight forward:
sep = re.compile('(\s*,*)+') print sep.split("""a@b.com, c@d.com e@f.com,,g@h.com""")
But this is not so. I cannot find a regex that does not leave any empty slots like:
['a@b.com', '', 'c@d.com', '', 'e@f.com', '', 'g@h.com']
I tried various combinations, but nobody works. Is this possible with regex?
python regex
interstar
source share