Sunday, November 13, 2011

UI String Matching in XAML and CS

A few month ago, we were doing String Localization for our software. It is lame for us to manually find the strings in the .cs and .xaml files and replace them with localization resource files.

So I look for help from REGEX, which is always helpful when dealing with strings.

Below is the regex to match UI String in xaml and cs files:

for .cs files:

^(~(ArgumentNullException|AddCMEventLog|//|dw\.add|OnPropertyChanged|Assembly\:|\[System\.|this\.RaisePropertyChanged|GeneratedCodeAttribute|throw\ new\ Exception).)+".*"(~(ArgumentNullException|AddCMEventLog).)+$

for .xaml files:

(Title="[^{])|(\ Text="[^{])|(Content="[^{])|(Header="[^{])|(ToolTip="[^{])|(Label="[^{])|(\ Value="[^{])|(Description="[^{])|(\>[^<>]+\<)

This may work in Visual Stdio only

No comments:

Post a Comment