I have a file with content like this:
<CdtrAgt>
<FinInstnId>
<BIC>HANDSESS</BIC>
<Nm></Nm>
<PstlAdr>
<Ctry>SE</Ctry>
</PstlAdr>
</FinInstnId>
</CdtrAgt>
<Cdtr>
<Nm> Very long company name here</Nm>
<PstlAdr>
<Ctry>SE</Ctry>
<AdrLine> Very long street address here</AdrLine>
</PstlAdr>
</Cdtr>
<CdtrAcct>
I need to find all occurrences of the Address and Name filed and trim this down to maximum 30 characters. So far I have this:
(Get-Content "P:\Economy\MonBet\Test.xml") |
Foreach-Object {$_ -replace "(?sm)<AdrLine>.*?</AdrLine>","<AdrLine></AdrLine>"} |
Foreach-Object {$_ -replace "(?sm)<Nm>.*?</Nm>","<Nm>$1</Nm>" } |
Out-File "P:\Economy\MonBet\Test2.xml"
But this only find and removes the text. How do I keep part of the text fond by my RegEx and insert it in my replace?