I use the regex [,;\s]+ to split a comma, space, or semicolon separated string. This works fine if the string doesn’t have a comma at the end:
>>> p=re.compile('[,;\s]+')
>>> mystring='a,,b,c'
>>> p.split(mystring)
['a', 'b', 'c']
When the string has a comma at the end:
>>> mystring='a,,b,c,'
>>> p.split(mystring)
['a', 'b', 'c', '']
I want the output in this case to be [‘a’, ‘b’, ‘c’].
Any suggestions on the regex?
Try: