正则替换

json = Regex.Replace(json, @"([\s\S]*?):([\s\S]*?),", "\"$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>[\s\S]*?)123)(?<img>[\s\S]*?)(?=456)");

 

 

火车头

<title>(?<content>[\s\S]*?)</title>

 

你可能感兴趣的:(正则替换)