问题源于这个帖子:
http://topic.csdn.net/u/20090608/11/6118ebe2-5ed5-4305-9947-d9573a26e764.html?seed=1379233329
我把这个问题转换成了7,9楼所述,最后我的实现方法是:
class CsToD
{
private string[] groups;
private string source;
public CsToD(string source, string[] groups)
{
this.source = source;
this.groups = groups;
}
public string Update(string newStr)
{
string target = source;
foreach (string g in groups)
{
Match m = Regex.Match(newStr, g);
if (m.Success)
target = Regex.Replace(target, g, m.Value);
}
return target;
}
}