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=.*?/> 

see demo.

  • the trick make sure don't past closing tag , end matching more text want.
  • if there nested <tags>, fail

explanation

  • (?s) activates dotall mode, allowing dot match across lines
  • <textblock matches 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= literal style=, \b on left ensure style not embedded in mystyle
  • .*? lazily matches characters to...
  • the closing />

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -