正则表达式替换Notepad ++中的字符串

时间:2016-07-29 06:36:35

标签: regex 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"/>

我想从这些字符串中替换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"/>

我使用下面的RE来匹配和替换

(<mycomponent id=".*?\.013D0E13-BF5F-4D0F-AAFA-FA4B120DE3E9)\S+ 

作为查找sting和$ 1作为替换字符串。事先找到了工作,替换不起作用

1 个答案:

答案 0 :(得分:2)

查找内容:(<mycomponent.*?)[.]013D0E13-BF5F-4D0F-AAFA-FA4B120DE3E9

替换为:$1

搜索模式:正则表达式

它也适用于this question

如果你想让它更通用于其他唯一标识符:

查找内容:(<mycomponent.*?id="[^"]*?)[.][A-Fa-f0-9\-]{36}
替换为:$1

相关问题