I would like to ignore the carriage-return line-feeds on the match, but keep them in what is selected. The "." symbol is defined as "matches any character except newline".
The following sample gives the desired results when the `n is removed. I want the XML Partner Tag. I was parsing in XML, but my output didn't seem to be compatible with the utility I'm using (BizTalk Import Binding for Parties).
$bindings = "starting stuff <Partner> more stuff <Name>CompanyName`n</Name> other things </Partner> ending stuff"
$partner = ""
$found = $bindings -match "(<Partner>.*<Name>CompanyName</Name>.*</Partner>)"
if ($found)
{
Write-Host "matched"
$partner = $matches[1]
}
Write-Host "partner=$partner "
I have also tried this:
$found = $bindings -match "(<Partner>[.\r\n]*<Name>CompanyName</Name>[.\r\n]*</Partner>)"