日期:2014-05-17  浏览次数:20883 次

C# 正则表达式替换,帮忙看下
后台返回了一段JSON数据,其中含有很多形如
"cE":"unlineExcel_CheckDate(C9,"0","2012-01-03","2013-08-01")"
这样的内容,影响解析
我想用正则表达式把所有类似这样的字符串括号里的双引号去掉

请问该如何解决

------解决方案--------------------
string tempStr = File.ReadAllText(@"C:\Users\myx\Desktop\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt
                tempStr = Regex.Replace(tempStr,@"(?<=\([^()]*?)""","");

                /*

                \"cE\":\"unlineExcel_CheckDate(C9,0,2012-01-03,2013-08-01)\"
                 */

------解决方案--------------------
yourstr=Regex.Replace(yourstr,"(?<=\()[^()]+(?=\))",m=>m.Value.Replace("\"",""));