Reputation: 47
I have an xml file which contains tags. I want to delete all <value>
tags from the file which contains an inner <isActive>
tag. I am trying this with regex find and replace in Notepad++.
I created this regex and i am not able to proceed further.
<value>.*?</value>
Below is the sample xml file`
<value>
<fullName>CMT - AAPAC - ANZ - Telstra - Media</fullName>
<default>false</default>
<label>CMT - AAPAC - ANZ - Telstra - Media</label>
</value>
<value>
<fullName>CMT - AAPAC - ASEAN - C&M - Comms</fullName>
<default>false</default>
<isActive>false</isActive>
<label>CMT - AAPAC - ASEAN - C&M - Comms</label>
</value>
The output of the file after removing should look like below
<value>
<fullName>CMT - AAPAC - ANZ - Telstra - Media</fullName>
<default>false</default>
<label>CMT - AAPAC - ANZ - Telstra - Media</label>
</value>
Upvotes: 1
Views: 567
Reputation: 627292
You can use
FindWhat: (?s)<value>(?:(?!<value>).)*?<isActive>.*?</value>
Replace With: (empty string)
See the regex demo online. Details:
(?s)
- .
matches newline mode on<value>
- a string(?:(?!<value>).)*?
- any char, zero or more occurrences, but as few as possible, that does not start value
substring<isActive>
- a string.*?
- any zero or more chars, as few as possible</value>
- a string.See demo and settings:
Upvotes: 1