正则替换

json = Regex.Replace(json, @"([sS]*?):([sS]*?),", ""$1":"$2",", RegexOptions.IgnoreCase);
     //string patten = "(?<=<input type="hidden" name="ts" value=")[\s\S]*?(?=")";
                        //html = Regex.Replace(html, patten, "6543255", RegexOptions.IgnoreCase | RegexOptions.Compiled);


//(?<=头部标记)[\s\S]*?(?=尾部标记)
//|<script id="ad]
string patten = "(?<=<div ad_dot_url)[\s\S]*?(?=<div id="sc|<script id="ad)";
html = Regex.Replace(html, patten, "", RegexOptions.IgnoreCase | RegexOptions.Compiled);
html = html.Replace("<div ad_dot_url", replacestr);


#region 搜狗替换

//html = html.Replace("src="/", "src="http://wap.sogou.com/");
//html = html.Replace("biz-icon.ttf", "http://wap.sogou.com/resource/web/font/iconfont.ttf");
//html = html.Replace("url(../images/", "url(http://wap.sogou.com/resource/web/images/");
//html = html.Replace("<link href="/resource", "<link href="http://wap.sogou.com/resource");

(?<=头部标记)[\s\S]*?(?=尾部标记)

(?<=头部标记[\s\S]*?头部2)[\s\S]*?(?=尾部标记)

  Regex pic_reg = new Regex(@"(?<=<123(?<title>[sS]*?)123)(?<img>[sS]*?)(?=456)");

火车头

<title>(?<content>[sS]*?)</title>

原文地址:https://www.cnblogs.com/wangchuang/p/5565096.html