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.5k Views 1 Watching
    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.
    • rajat narangR Offline
      rajat narang
      last edited by

      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>

      astrosofistaA 1 Reply Last reply Reply Quote 0
      • astrosofistaA Offline
        astrosofista @rajat narang
        last edited by

        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
        • rajat narangR Offline
          rajat narang
          last edited by

          @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

          astrosofistaA 1 Reply Last reply Reply Quote 2
          • astrosofistaA Offline
            astrosofista @rajat narang
            last edited by

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

            PeterJonesP 1 Reply Last reply Reply Quote 3
            • PeterJonesP Online
              PeterJones @astrosofista
              last edited by

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

              astrosofistaA 1 Reply Last reply Reply Quote 4
              • astrosofistaA Offline
                astrosofista @PeterJones
                last edited by

                @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

                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
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors