Home > Back-end >  How to use regexp on notepad ?
How to use regexp on notepad ?

Time:04-06

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

CodePudding user response:

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

  • Related