• Login
Community
  • Login

Run multiple search and replace - one after another

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
search miltiple
5 Posts 3 Posters 130 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
    Ramses505
    last edited by Apr 14, 2025, 9:07 PM

    I have a few search and replace combinations that I use frequently that mostly work - but I usually need to run maybe 3 of them one after another - kind of like this;
    1.
    To remove incorrect CRLF – start with the following
    Remove CRLF for sentences ending in lower case letter;
    Search ([a-z])\R
    Replace \1
    2.
    Remove CRLF for sentences ending in hyphen;
    Search -\R
    Replace NOTHING
    3.
    ! Remove COMMA (,) for sentences ending in COMMA (,);
    Remove CRLF (,) for sentences ending in COMMA (,);

    Search ,\R
    Replace NOTHING

    Is there a way I can run these with a script or something like that ? As you might see I need to keep a list of them all which I then have to copy and paste into the editor one after another and mistakes often happen :-(

    Any help would be much appreciated and I am anxious to learn.

    Thanks

    T 1 Reply Last reply Apr 14, 2025, 9:10 PM Reply Quote 0
    • T
      Terry R @Ramses505
      last edited by Apr 14, 2025, 9:10 PM

      @Tobias-Ray

      Yes, in a word “Macro”.

      It is just the saving of the keystrokes and regular expressions in whatever function (Find, Replace). Once saved and given a name and possibly a shortcut mapping you can run it anytime you wish.

      Best to read the online manual, it explains it there.

      Terry

      1 Reply Last reply Reply Quote 3
      • M
        Mark Olson
        last edited by Apr 14, 2025, 9:43 PM

        @Ramses505

        TerryR omitted a link to the documentation. Here it is .

        R 1 Reply Last reply Apr 15, 2025, 5:16 PM Reply Quote 2
        • R
          Ramses505 @Mark Olson
          last edited by Apr 15, 2025, 5:16 PM

          Thank you Terry and Mark. @Mark-Olson
          Out of interest - can I run some sort of python script that would do this as well ?

          Thanks for taking the time to read and answer, appreciated.

          M 1 Reply Last reply Apr 15, 2025, 5:38 PM Reply Quote 0
          • M
            Mark Olson @Ramses505
            last edited by Mark Olson Apr 15, 2025, 5:38 PM Apr 15, 2025, 5:38 PM

            @Ramses505 said in Run multiple search and replace - one after another:

            Out of interest - can I run some sort of python script that would do this as well ?

            Yes. If you already know Python, the PythonScript plugin can let you automate Notepad++ with Python.

            If you don’t know Python, this forum is not the place to discuss how to learn Python. There are countless tutorials on the internet for that purpose. I’ll just mention the re library and leave it at that.

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