• Login
Community
  • Login

How to replace all content from XML tag with blank in notepad++?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 3 Posters 2.0k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R
    rajat narang
    last edited by Jun 11, 2020, 1:23 AM

    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>

    A 1 Reply Last reply Jun 11, 2020, 2:49 AM Reply Quote 0
    • A
      astrosofista @rajat narang
      last edited by Jun 11, 2020, 2:49 AM

      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 around option
      Select the Regular expression search mode
      Click on the `Replace All´´ button

      Hope this helps.

      1 Reply Last reply Reply Quote 2
      • R
        rajat narang
        last edited by Jun 11, 2020, 3:17 AM

        @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

        A 1 Reply Last reply Jun 11, 2020, 12:27 PM Reply Quote 2
        • A
          astrosofista @rajat narang
          last edited by Jun 11, 2020, 12:27 PM

          @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.

          P 1 Reply Last reply Jun 11, 2020, 1:05 PM Reply Quote 3
          • P
            PeterJones @astrosofista
            last edited by Jun 11, 2020, 1:05 PM

            @astrosofista ,

            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 the s flag 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. ;-)

            A 1 Reply Last reply Jun 11, 2020, 2:20 PM Reply Quote 4
            • A
              astrosofista @PeterJones
              last edited by Jun 11, 2020, 2:20 PM

              @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

              1 Reply Last reply Reply Quote 3
              1 out of 6
              • First post
                1/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors