I want to split some text by these delimiters: ",", ";", " y " (whitespace is necessary)
It should also ignore any delimiters within parentheses
Here's what I've tried for the first two:
re.split('[,;]+(?![^(]*\))', text_spam)
'foo, bar; baz spam y eggs guido'
should split into ['foo', ' bar', ' baz spam', 'eggs guido']
I can't figure out how to include a multicharacter string inside the set to get the last delimiter.
TIA
r'(?:[,;]| y )+(?![^(]*\))'? Did you try alternation?