I need to find all instances of strings within an xml node. To be more specific, I’d like to parse some XAML and place all strings within certain controls (label for one) and set them as attributes instead. So, instead of this
<Label>My string</Label>
I want this:
<Label Content="My string"></Label>
The regular expression I have come up with is “>\s*[^<]”. I read this as matching strings that have a greater than sign, followed by any amount of whitespace, followed by any character other than the less than sign. However, I’m not getting what I expect. For instance, here is one of the matches:
>\\r\\n\\t\\r\\n <UserControl..."
Any ideas?
You could search for
and replace that with
or even
IF you’re absolutely sure that there won’t be any nested tags among those that you’re looking at, and there really is no other way but regex.