启用GB2312编码
var ROOT = AppDomain.CurrentDomain.BaseDirectory;
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var Encoding_GB2312 = Encoding.GetEncoding("GB2312");
C#正则替换
正则转义字符为\
string input1 = @"<img src=""file://c:\abc.png""></img>";
string pattern1 = @"<(.*?) ";
string replacement1 = @"<$1 aa ";
var val1 = Regex.Replace(input1, pattern1, replacement1);
结果为:<img aa src=""file://c:\abc.png""></img>
string input2 = @",14.14.69.128,";
string pattern2 = @",(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,}),";
string replacement2 = @",""$1.$2.$3.$4"",";
var val2 = Regex.Replace(input2, pattern2, replacement2);
结果为:,"14.14.69.128",