0

I'm writing a script that replaces and delete some commented lines but the problem is the .xml file got more than only one thing which is commented and I only have to uncomment one of these. It would be no problem if there's everything written on one line but it's not.

XML looks like this:

<!--
<session-config>
    <anything>
</session-config>
-->
<!--
<something-else>
    <session-timeout>120</session-timeout>
</something-else>
-->

So: I need to remove <!-- and --> by the <session-config>, </session-config> but NOT by the <something-else>, </something-else>!! And if I use -replace "<!--", "" it will delete the comment as well by <something else> and this is not what I want.

mklement0
  • 382,024
  • 64
  • 607
  • 775
  • 1
    As long as the replacement is being performed on a single string `-replace '(?s), '$1'`. That should remove comments and keep the data where "" appears in between. [regex link](https://regex101.com/r/zixpbb/1) – Matt Nov 23 '17 at 13:51
  • The variable $1 is this the normal one without comments? – Manuel Hedinger Nov 24 '17 at 13:11

0 Answers0