I looked at the answers to this previously asked question:
Split strings with multiple delimiters?
For my version of this problem, I wanted to separate everything that wasn’t from a specific character set. This led me to a solution that I liked, until I discovered this obvious error. Is this a mistake or some python quirk I am not familiar with?
>>> b = "Which_of'these-markers/does,it:choose to;split!on?"
>>> b1 = re.split("[^a-zA-Z0-9_'-/]+", b)
>>> b1
["Which_of'these-markers/does,it", 'choose', 'to', 'split', 'on', '']
I don’t understand why it is not split into a comma (','), given that the comma is not in my exception list?
source
share