• Login
Community
  • Login

Find and Replace multiple lines of XML

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 376 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.
  • A
    Andreas Kraus
    last edited by Jun 7, 2024, 10:55 AM

    Hi!

    I’m a complete newb when it comes to regex. For work, I have to clean a huge XML file for our customer. It’s basically 250+ Data Operations that contain tons of internal technical information, as well as some data that is relevant for our customer. I’ve been able to remove unnecessary lines by using this Regex line that I found using Google.

    (?-s)<exampletag>(.*?)</exampletag>
    

    However, I have one field (<errorDetails>) that is several hundred lines long for each Data Operation that I need to remove and the above regex doesn’t seem to work when the content isn’t all in one line. Is there any way for me to easily remove the <errorDetails> + </errorDetails> and everything in between? Unfortunately, while it is the same error for each Operation, the error message contains several identifiers, table names and the like, so the content in between the tags is unique for each operation.

    Ticking “matches newline” did not work.

    Thanks for your assistance!

    A 1 Reply Last reply Jun 7, 2024, 11:00 AM Reply Quote 1
    • A
      Alan Kilborn @Andreas Kraus
      last edited by Jun 7, 2024, 11:00 AM

      @Andreas-Kraus

      The (?-s) in your expression is the problem.
      That is roughly equivalent to leaving “. matches newline” uncheckmarked, and also note that it overrides the state of “. matches newline” (so if you use (?-s) in your expression, the state of “. matches newline” does not matter at all).

      Try changing (?-s) to (?s).
      OR, remove (?-s) entirely and then checkmark “. matches newline”.

      A 1 Reply Last reply Jun 7, 2024, 11:23 AM Reply Quote 2
      • A
        Andreas Kraus @Alan Kilborn
        last edited by Jun 7, 2024, 11:23 AM

        @Alan-Kilborn Thank you so much, that worked beatifully

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