string mystr = "<font color='red'>red test</font>";Regex.replace(mystr, "(?<=^[^<]*|>[^<]*)red","black",RegexOptions.Multiline); 结果: "<font color='red'>black test</font>";