samedi 9 mai 2015

Python re.sub() Look ahead then look behind

I want to remove all occurrence of ' except when it indicates posession

Example:

>>> 'this' needs to g'o'
this needs to go
>>> even though this' is not right it can stay
even though this' is not right it can stay
>>> Some peoples' 'kids'
some peoples' kids

exceptions:

 >>>Andrea 's b'a'l'l' 'g'o't' 'dropped (I already insert a space between the name and 's)
Andrea 's ball got dropped

Aucun commentaire:

Enregistrer un commentaire