Search and Replace in textpad/notepadd++ using RegEx

倖福魔咒の 提交于 2019-12-11 13:38:50

问题


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


回答1:


You can do:

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

Demo



来源:https://stackoverflow.com/questions/35817020/search-and-replace-in-textpad-notepadd-using-regex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!