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

Nico Grubert nicogrubert at arcor.de
Thu Nov 25 09:43:53 EST 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>*'.

Example:
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,
Nico



More information about the Python-list mailing list