[英]Regex to replace string in Notepad++
Hi i am trying to write a regular expression for matching and replacing below strings using Notepad++ 嗨,我正在尝试编写一个正则表达式,以使用Notepad ++匹配和替换以下字符串
<mycomponent id="Myvalue1.013D0E13-BF5F-4D0F-AAFA-FA4B120DE3E9" test="my" value="1234"/>
<mycomponent id="Myvalue3.013D0E13-BF5F-4D0F-AAFA-FA4B120DE3E9" kv="ggg" propert="null"/>
<mycomponent id="Myvalue5.013D0E13-BF5F-4D0F-AAFA-FA4B120DE3E9" fff="ddd" key="kk"/>
<mycomponent id="Myvalue7.013D0E13-BF5F-4D0F-AAFA-FA4B120DE3E9" dfd="drgf"/>
I want to replace 013D0E13-BF5F-4D0F-AAFA-FA4B120DE3E9 from these string and result should be as given below 我想从这些字符串中替换013D0E13-BF5F-4D0F-AAFA-FA4B120DE3E9,结果应如下所示
<mycomponent id="Myvalue1" test="my" value="1234"/>
<mycomponent id="Myvalue3" kv="ggg" propert="null"/>
<mycomponent id="Myvalue5" fff="ddd" key="kk"/>
<mycomponent id="Myvalue7" dfd="drgf"/>
I used the below RE for matching and replacing 我使用以下RE进行匹配和替换
(<mycomponent id=".*?\.013D0E13-BF5F-4D0F-AAFA-FA4B120DE3E9)\S+
as the find sting and $1 as the replace string. 作为查找字符串,$ 1作为替换字符串。 Eventhought the find is working the replace is not working
即使发现仍然有效,替换却不起作用
Find What: (<mycomponent.*?)[.]013D0E13-BF5F-4D0F-AAFA-FA4B120DE3E9
查找内容:
(<mycomponent.*?)[.]013D0E13-BF5F-4D0F-AAFA-FA4B120DE3E9
Replace with : $1
替换为:
$1
search mode : Regular Expression 搜索模式:正则表达式
It will also work for this question 这也将解决这个问题
And if you want to make it more general for other unique identifiers: 如果您想使其更通用于其他唯一标识符:
Find What: (<mycomponent.*?id="[^"]*?)[.][A-Fa-f0-9\\-]{36}
查找内容:
(<mycomponent.*?id="[^"]*?)[.][A-Fa-f0-9\\-]{36}
Replace with : $1
替换为:
$1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.