mystack
mystack

Reputation: 5532

Regex to replace string in Notepad++

Hi i am trying to write a regular expression for matching and replacing below strings using 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

  <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

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

as the find sting and $1 as the replace string. Eventhought the find is working the replace is not working

Upvotes: 0

Views: 355

Answers (1)

LukStorms
LukStorms

Reputation: 29677

Find What: (<mycomponent.*?)[.]013D0E13-BF5F-4D0F-AAFA-FA4B120DE3E9

Replace with : $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}
Replace with : $1

Upvotes: 2

Related Questions