要求如下:
查找下面样子的代码.并返回找到的代码.应该怎么写?
ation("test")="content"
ation("test")="why"
ation("test")="whis"例如我长到ation("test")="content"内容.就返回ation("test")="content"
例如我长到ation("test")="why"内容.就返回ation("test")="why"
查找下面样子的代码.并返回找到的代码.应该怎么写?
ation("test")="content"
ation("test")="why"
ation("test")="whis"例如我长到ation("test")="content"内容.就返回ation("test")="content"
例如我长到ation("test")="why"内容.就返回ation("test")="why"
MatchCollection mc = Regex.Matches(yourStr, "ation\\(\"(?<key>.+?)\"\\)\\s*=\\s*\"(?<value>.+?)\"");
foreach(Match m in mc)
{
m.Value;
m.Groups["key"].Value;
m.Groups["value"].Value;
}
ation\(\"test\"\)=\"(content|why|whis)\"
string yourStr = ......;
MatchCollection mc = Regex.Matches(yourStr, "ation\\(\"(?<key>.+?)\"\\)\\s*=\\s*\"(?<value>.+?)\"");
foreach(Match m in mc)
{
m.Value;
m.Groups["key"].Value;
m.Groups["value"].Value;
}
经典!
传入test1,返回ation("test1")="content"
传入test2,返回ation("test2")="why"
谢谢!