您的位置:首页 > 其它

正则替换

2016-06-06 21:15 253 查看
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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: