Community
    • Login

    How can I replace multiple words in a file

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 610 Views 2 Watching
    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 Offline
      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 Offline
        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 Offline
          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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors