I wonder if the following can be done reliably by regex, or should I stick to plain string manipulation in Python? Performance is very important.
German apple is good. Apple is nice. Where is the apple? English apple have worms. English people are nice.
- I would like to replace all occurrences of
AppleorapplewithGerman apple. - However if apple has the adjective English,
Englishshould be replaced byGerman. English peoplewon't change, because people aren't apples.
I am not really an expert in regex. There are some online generators, such as this http://www.regexr.com/
I tried this and it gives me only the first apple. \b(apple)
Any help would be much appreciated
Aucun commentaire:
Enregistrer un commentaire