正则替换
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>
相关文章推荐
- 命令行式下java package的编译与运行注意事项
- Word Pattern
- Quartz以及代码实现--可以实现定时器效果
- 自定义特色组件
- 深入理解Redis中的主键失效及其实现机制
- 可伸缩堆(heap)的面向对象的C实现
- 程序集清单文件
- 二叉树的路径输出
- javac找不到或无法加载主类 com.sun.tools.javac.Main
- 项目管理工具:Maven使用方法总结
- 176. Second Highest Salary
- 自动轮播
- 依赖注入?Dagger?
- iOS中的触摸事件和手势处理
- js(javascript)中的奇特for循环写法!
- Android练手——分贝计
- asp.net控件汇总
- 跟我一起学C++之从C到C++(结构体内存对齐)
- 淘宝运营中的6大致命误区,你犯过么?
- Java 虚拟机总结 - JVM 内存区域