More specifically I want to split a string on any non alpha-numeric character but in the case that the delimiter is not a white space I want to keept it. That is, to the input:
my_string = 'Hey, I\'m 9/11 7-11'
I want to get:
['Hey' , ',' , 'I' , "'" , 'm', '9' , '/' , '11', '7' , '-' , '11']
Without no whitespace as a list element.
I have tried the following:
re.split('([/\'\-_,.;])|\s', my_string)
But outputs:
['Hey', ',', '', None, 'I', "'", 'm', None, '9', '/', '11', None, '7', '-', '11']
How do I solve this without 'unnecessary' iterations?
Also I have some trouble with escaping the backslash character, since '\\\\'
does not seem to be working, any ideas on how to also solve this?
Thanks a lot.