I am trying to modify config.xml.
config.xml content is
<command>
some lines here 2
</command>
some lines here 3
So I want to replace the content between <command> and </command>. Here is what I tried doing
$Replace = Get-Content D:\Temp\Replace.txt
$ReplaceWith = Get-Content D:\Temp\ReplaceWith.txt
$regex = '(<command>\d*).*?(</command>\d*)'
$Replace -replace $regex, $ReplaceWith
But its not working. Need help.
-RawwithGet-Contentand also add(?s)at the regex start. Also, if yourreplaceWith.txtcontains plain text (not a specifically formatted regex replacement string) and if you have$in the replacement, you need to double them and remove\d*and parentheses.(<command>)[\S\s]+(<\/command>)? ;).xmlwith regex. Instead, read asxmland either dot index ($myconfig.topnode.othernode.command) orSelectNode