Splitting a string

Nico Grubert nicogrubert at gmail.com
Tue Feb 14 02:49:53 EST 2006


Dear Python users,

I'd like to split a string where 'and', 'or', 'and not' occurs.

Example string:
s = 'Smith, R. OR White OR Blue, T. AND Black AND Red AND NOT Green'

I need to split s in order to get this list:
['Smith, R.', 'White', 'Blue, T.', 'Back', 'Red', 'Green']

Any idea, how I can split a string where 'and', 'or', 'and not' occurs?


Thank you very much in advance,
Nico



More information about the Python-list mailing list