How to replace all content from XML tag with blank in notepad++?
-
I would like to remove all content from id=“*” within a tag and replace with blank. There are 100s of different id values and I would like to remove all of it.
<Type>Computer</Type>
<deductible id=“d6349782384236423784ABD#1212” >
<Type>Standard</Type>
</deductible>
<limit id=“1123123VHGHJKJH65776BJHBHG9”>
<Type>Aggregate</Type>
<ivalue>10000</ivalue>I want output like this:
<Type>Computer</Type>
<deductible>
<Type>Standard</Type>
</deductible>
<limit>
<Type>Aggregate</Type>
<ivalue>10000</ivalue> -
Hi @rajat-narang, All:
-Try this:
Open the Replace dialog (
Ctrl + H) and type in:Search: (?-s)\x20id="[^"]+"\x20? Replace: [leave empty]or (if curly quotes are used)
Search: (?-s)\x20id=“[^”]+”\x20? Replace: [leave empty]Check the
Wrap aroundoption
Select theRegular expression search mode
Click on the `Replace All´´ buttonHope this helps.
-
@astrosofista said in How to replace all content from XML tag with blank in notepad++?:
(?-s)\x20id=“[^”]+”\x20?
Thank you so much ! It worked perfectly
-
@rajat-narang said in How to replace all content from XML tag with blank in notepad++?:
Thank you so much ! It worked perfectly
Glad it helped you.
BTW, I forgot to remove the (?-s) modifier, as the
*is not used in the expression. It does no harm, but it’s useless. -
BTW, I forgot to remove the (?-s) modifier, as the
*is not used in the expression. It does no harm, but it’s useless.Nitpick: it’s the
.operator that is affected by(?-s), not the*, since thesflag is “dot matches newline”. But.wasn’t used in your expression, either, so the flag-clearing is still useless. :-)Well, not completely useless. As we help people in the forums, always including either
(?-s)or(?s)will ensure we never have to care what the status of their checkbox is, so having one of the two in our default answer-regex is a good idea. ;-) -
@PeterJones said in How to replace all content from XML tag with blank in notepad++?:
Nitpick: it’s the . operator that is affected by (?-s), not the *, since the s flag is “dot matches newline”. But . wasn’t used in your expression, either, so the flag-clearing is still useless. :-)
Yep, my bad, I stated a wrong reason, thank you for notice it :)
Well, not completely useless. As we help people in the forums, always including either (?-s) or (?s) will ensure we never have to care what the status of their checkbox is, so having one of the two in our default answer-regex is a good idea. ;-)
Agree, learned that in this forum, so the (?-s) modifier is my default setup.
Cheers
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login