I have huge amount XML files and I need to remove attributes with specific content.
<Image Width="214.57"
Height="165"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Source="{DynamicResourceExtension ResourceKey=images_4bd6348715-testImage.jpg}"
Canvas.Left="8"
Canvas.Top="24" />
First case:
Operator can enter images_4bd6348715-testImage.jpg and attribute Source should be removed.
Attribute can have any name.
Second case:
Text can be inside node. Node can have any name:
<Image Width="214.57"
Height="165"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Canvas.Left="8"
Canvas.Top="24" >
<Image.Source2>
<DynamicResource>
<DynamicResource.ResourceKey>
images_4bd6348715-testImage.jpg
</DynamicResource.ResourceKey>
<DynamicResource>
</Image.Source2>
</Image>
In both cases i only know that inside attribe or node i will have DynamicResource or DynamicResourceExtension
How can i do this with Regex query?
My attemts: First case:
\w+[.]?\w+\s*[=]\s*["]\s*[{]\s*[_.\s{=}a-zA-Z0-9]*images_4bd6348715-testImage.jpg[_.\s{=}a-zA-Z0-9]*\s*}\s*["]