Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use regexp on notepad++?

I have a file with 5k lines and need to replace a piece of code in all:

(1, 'aaaaaa...
(2, 'aaaaaa...
(3, 'aaaaaa...
...
(4999, 'aaaaaa...
(5000, 'aaaaaa...

I need to delete or replace the (1, 'aaaaa to ('aaaaaa like:

('aaaaaa...
('aaaaaa...
('aaaaaa...
...
('aaaaaa...
('aaaaaa...

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Open the replace option on the menu

Check the regex option so the search function will use regex

  • in the find section type : ^(\(\d+,)(.*)
  • in the replace section type : \($2 (edited based on OP’s comment) now, its been a while since I used N++ it this doesn’t work try using \2 instead of $2

What it does is:

  • find anything that starts with a ( followed by a digit 1-many times and a comma, group as 1
  • Anything after the first group, group as 2
  • in the replace: it adds a ( and whatever is in group 2

Here is an example of how it would work: https://regex101.com/r/Xomq2Y/1

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading