regexnotepad++textpad

Search and Replace in textpad/notepadd++ using RegEx


I need to do search and replace in textpad or notepad++. So I am trying to use Regular Expressions. I have some lines like below

(C_ABCD_ehfjdhf dj hfdjhfhj and
(S_dfdfdddff 20 and
(P_ABCD_fmngfngm gfnm and

I need to check for the key word ABCD and if found , add a constant value before the last word. In result I want above lines to be as follows

(C_ABCD_ehfjdhf dj hfdjhfhj CONSTANT and
(S_dfdfdddff 20 and
(P_ABCD_fmngfngm gfnm CONSTANT and

Since first and third line had the keyword ABCD, the term CONSTANT needs to be added before ending word

I had raised a similar question before but I think I was not able to explain the problem correctly. Here is the link for that

Regular expressions to replace


Solution

  • You can do:

    (ABCD[\w\s]+)( [a-zA-Z]+)$
    

    Demo