Run multiple search and replace - one after another
-
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 NOTHINGIs 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
-
@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
-
TerryR omitted a link to the documentation. Here it is.
-
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.
-
@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.