{string1}={string2}
匹配上面这个字符串,并把其中的string1和string2提取出来。
我是这样写的,可是不对:
@"^{(<name>)}={(<value>)}$"
match.Result("${name}")
match.Result("${value}")
匹配老是没成功。我想可能是由于“{”和“}”为特殊字符吧,但是不知道如何处理,请指点,谢谢!
匹配上面这个字符串,并把其中的string1和string2提取出来。
我是这样写的,可是不对:
@"^{(<name>)}={(<value>)}$"
match.Result("${name}")
match.Result("${value}")
匹配老是没成功。我想可能是由于“{”和“}”为特殊字符吧,但是不知道如何处理,请指点,谢谢!
Match match = Regex.Match(str, @"^{(\w+)}={(\w+)}$");
string ret1 = match.Groups[1].Value;
string ret2 = match.Groups[2].Value;
Match match = Regex.Match(s, @"^(\{\w+\})=(\{\w+\})$");
Console.WriteLine(match.Result("$1"));
Console.WriteLine(match.Result("$2"));
Match match = Regex.Match(s, @"^\{(?<name>.+)\}=\{(?<value>.+)\}$");
Console.WriteLine(match.Result("${name}"));
Console.WriteLine(match.Result("${value}"));
我不知道(?<name>.+)中的?是起什么作用?找了找资料没有介绍,能否麻烦你解释一下。
希望能给我分析一下这个(?<name>.+),谢谢!
分不够,待会我另外找个帖子给你补分,谢谢!