c# - find xaml text with regular expression -
how find textblocks in xaml files contains style parameter using search in microsoft visual studio. there regexp possible used here? here example of block:
<textblock text="{binding localizedresources.boom, source={staticresource localizedstrings}}" foreground="{staticresource gray}" textwrapping="wrap" style="{staticresource sdfsdf}" horizontalalignment="center" visibility="{binding erroroccured,converter={staticresource tovisibilityconverter},converterparameter=true}"/> thanks.
since you're in editor, usual warnings using regex parse xml can relaxed (only bit)...
this work:
(?s)<textblock(?:(?!/>).)*?\bstyle=.*?/> - the trick make sure don't past closing tag , end matching more text want.
- if there nested
<tags>, fail
explanation
(?s)activatesdotallmode, allowing dot match across lines<textblockmatches literal characters- the non-capturing group
(?:(?!/>).)matches 1 character, long not followed/>(this avoid jumping out of present tag) *?allows type of character mentioned mach lazily, 0 or more times, to...\bstyle=literalstyle=,\bon left ensurestylenot embedded inmystyle.*?lazily matches characters to...- the closing
/>
Comments
Post a Comment