samedi 9 mai 2015

re.sub() negative look behind + negative look ahead

Remove every occurence of ' from a string except when it is found before an 's or after an s'. with the exception being if it encapsulated the whole word it should be removed.

Example:

Andrea's -Stays as is
Kids' - stays as is
'Kids' --> Kids
Ki'd's' --> Kids

WHat I came up with so far :

\'(?!s ) 

this matches the first example and ignores it.

here is it working

I have a problem with the rest

Aucun commentaire:

Enregistrer un commentaire