Replacing words from strings except 'and' / 'or' / 'and not'

Nico Grubert nicogrubert at
Thu Nov 25 15:43:53 CET 2004

Hi there,

Background of this question is:
I want to convert all words <word> except 'and' / 'or' / 'and not' from 
a string into '*<word>*'.

I have the following string: 
"test and testing and not perl or testit or example"

I want to convert this string to:
'*test*' and '*testing*' and not '*perl*' or '*testit*' or '*example*'

Any idea, how to do this?

Thanks in advance,

More information about the Python-list mailing list