Regex to replace a specific word
Let’s say I must replace “word2” on a document by “word3”, but only when the line starts by “word1”.
I’m not familiar with regex and less with regex in notepad++.
So I started do it this way and this part seems to work :
Find field ==> (?:.word1)(?:.*word2)
I tried in the replace field ==> (?:.word1)(?:.*word3) but it replaced all the found lines by “(?:.word1)(?:.*word3)”
Can you please help me to do it ? Something like 10 000 files to check for several replaces needed, I’ll be mad before I end it if I have to do it manually :D
Debug info :
Notepad++ v8.4.7 (64-bit)
Build time : Nov 1 2022 - 23:31:11
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
OS Name : Windows 10 Pro (64-bit)
OS Version : 22H2
OS Build : 19045.2364
Current ANSI codepage : 1252
I think you want this “recipe”:
See if you can make sense of that and how you might apply it to your situation.
Thanks for the link. Using this one and some others I was able to do what I wanted … almost
I wasn’t good enough to deal with all the cases only with regex and I had to modify some cases manually, not a lot fortunately.
Using this one and some others I was able to do what I wanted … almost
I wasn’t good enough to deal with all the cases only with regex and I had to modify some cases manually
Hopefully it wasn’t a defect/limitation of the technique in the link I provided.