Community
    • Login

    How can I replace multiple words in a file

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 291 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      ramakrishna
      last edited by

      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…

      Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @ramakrishna
        last edited by Alan Kilborn

        @ramakrishna

        Something like this maybe:

        Find: (car)|(flight)|(boat)
        Replace: (?1bus)(?2jet)(?3ship)
        Search mode: Regular expression

        You 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.

        1 Reply Last reply Reply Quote 4
        • PeterJonesP
          PeterJones @ramakrishna
          last edited by

          @ramakrishna ,

          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 and flight => jet conversion.

          1 Reply Last reply Reply Quote 4
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors