c# - Regex: Keep unkknown substring -
i try modify set of strings. need replace unknown parts keep unkknown middle part. in notepad++ used
as regex-input: .*(themeresource .*?brush).*
and regex-output: /1
with result:
input:
"<setter property="foreground" value="{themeresource systemcontrolforegroundbasehighbrush}" />" "<setter property="background" value="{themeresource systemcontrolbackgroundaltmediumlowbrush}" />" "<setter property="borderbrush" value="{themeresource systemcontrolforegroundbasemediumlowbrush}" />" "<discreteobjectkeyframe keytime="0" value="{themeresource systemcontrolpagebackgroundaltmediumbrush}" />"
output:
"themeresource systemcontrolforegroundbasehighbrush" "themeresource systemcontrolbackgroundaltmediumlowbrush" "themeresource systemcontrolforegroundbasemediumlowbrush" "themeresource systemcontrolpagebackgroundaltmediumbrush"
but c#-regex output allways: "/1"
i guess, there fundamental differences between c# , notepad++ regex, not understand change, since regex-input-selection seems work expected.
edit:
my code:
list<string> ls = file.readlines(@"c:\cbtemplate.xml").tolist().select(x=>regex.replace(x, ".*{(themeresource .*?brush).*", @"\1"));
my notepad++ "find , replace":
to capturing group, use $1
instead of /1
:
list<string> ls = file.readlines(@"c:\cbtemplate.xml").tolist().select(x=>regex.replace(x, ".*{(themeresource .*?brush).*", @"$1"));
Comments
Post a Comment