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.
    • Andreas KrausA
      Andreas Kraus
      last edited by

      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!

      Alan KilbornA 1 Reply Last reply Reply Quote 1
      • Alan KilbornA
        Alan Kilborn @Andreas Kraus
        last edited by

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

        Andreas KrausA 1 Reply Last reply Reply Quote 2
        • Andreas KrausA
          Andreas Kraus @Alan Kilborn
          last edited by

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

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