regex match for string in Xml file

Hi folks. I almost had this project wrapped up but got stuck with some odd XML file string match issue. I have the correct Regex code below to capture the 2 items below. But the problem i have is any single XML file we parse thru, may have either of the two xml element values in them. To explain clearly, the 1st XML snippet below ending with “bravo2.gif” is followed by a > character (NO empty spaces). The 2nd XML snippet further below ending with “FaxDoc1.jpg” is followed by a single space and /> characters. The problem i’m trying to figure out is how to combine the two Regex code so that when parsing thru XML files, the pattern search will now how to look for either Regex queries and pickup only the string between the double quotes, so the value for xlink:href. The hundreds of XML files, may have image references that either have a space or they do not (like 2 examples below). Thanks for any assistance.


$xmlDoc.InnerXml | Out-String | % {[Regex]::Matches($, “(?<=ext-link xlink:show=”“embed”" xlink:href=)((.|\n)*?)(?=>)")} | % {$.Value}

<ext-link xlink:show=“embed” xlink:href=“…/…/…/Content/images/bravo2.gif”>


$xmlDoc.InnerXml | Out-String | % {[Regex]::Matches($, “(?<=ext-link xlink:show=”“embed”" xlink:href=)((.|\n)*?)(?=\s/>)")} | % {$.Value}

<ext-link xlink:show=“embed” xlink:href=“…/…/…/Content/images/FaxDoc1.jpg” />

Moderators - please delete this. The issue resolution was not Regex related, used TrimEnd(’ /') to fix the problem at hand. Thanks