Find and Replace multiple lines of XML
-
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!
-
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”. -
@Alan-Kilborn Thank you so much, that worked beatifully