How can I replace multiple words in a file
-
I need to replace multiple words in a file. I have upto 700 words to replace. we are not sure if all the 700 words are used in that file so we need to check if a used then replace it with another word from list of 700 words we have.
For example we have a list as a below
Car as bus
flight as jet
boat as ship
apple as fruit and so on… -
Something like this maybe:
Find:
(car)|(flight)|(boat)
Replace:(?1bus)(?2jet)(?3ship)
Search mode: Regular expressionYou can do more than 3 items at once; I think you see the pattern.
Note that there is a length restriction of 2046 bytes in the expressions, so you may need to set up more than one set of such replacements.
-
As an alternative, in this post, I shared a script for the PythonScript plugin that allows you to define a list of “translations” – as many as you want. In that example, it was translating from an English term to a foreign language equivalent. However, you could fill out the translation table in the script to do your
car => bus
andflight => jet
conversion.