Here is the powershell script
$configFiles = Get-ChildItem . *.scd -rec
foreach ($file in $configFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object {
$_ -replace '<Terminal .+\/>', '' `
-replace '<Terminal [.|\n]*?<\/Terminal>', '' `
-replace '<Private type=\"ABB.*?<\/Private>', '' `
-replace '<ConnectivityNode.*?>.*?<\/ConnectivityNode>', '' `
-replace '\r\n[\t\n\v\f\r ]+\r\n', '\r\n'
} |
Set-Content $file.PSPath
}
The first replace is working just fine because the tag is single line but the rest are not working, nothing happens as they have other tags inside them as well. I wanted to know what's the correct Regular expression.
This is the group of tags that i want to replace(2nd replace) with ' ' what regular expression would work?
<Terminal name="T_grounded" connectivityNode="AA1/J1/Q01/grounded"
substationName="AA1" voltageLevelName="J1" bayName="Q01"
cNodeName="grounded">
<Private type="ABB SLD">
<esld:Line>
<esld:Via x="244" y="116" />
</esld:Line>
</Private>
</Terminal>
In Notepad++ it's pretty simple as you can just mark . matches new line and replace all but i don't know how we will adapt it in powershell script.
Thanks in advance, please help me out.