摘要:string s="uid=aaaaaaaaaaaa</a>||||||||||||||Uid=bbbbbbbbbbbbbbbbbb</a>||||||||||||||Uid=cccccccccccccc</a>||||||||||||||Uid=dddddddddddddddd</a>";//temp 存放匹配结果string temp="";//results 正则捕获结果集合MatchCollection results = Regex.Matches(s,"uid=(?<txt>
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.IO;using System.IO.Compression;using System.Text.RegularExpressions;namespace WikiPageCreater.Common{ public class PageHelper { /// <summary> /// 根据 url 获取网页编码 /...
阅读全文
摘要:public string GetSubValue(string str, string s, string e) { Regex rg = new Regex("(?<=(" + s + "))[.\\s\\S]*?(?=(" + e + "))", RegexOptions.Multiline | RegexOptions.Singleline); return rg.Match(str).Value; }
阅读全文
摘要:【IT168技术文档】如何使用C#和正则表达式截取html代码呢,如何处理html代码中的\r\n这样的字符呢,下面我们来一起研究一下,先从截取目标开始。一、代码说明 1.以下html表示收到的3个组的信息,如果含有"unread.gif"表示未读消息,否则表示已读信息。 2.截取未读消息和已读消息的条数和theUrl 3.要将未读信息和已读信息分开放入两个组里。 <div class="dxx_of" id="message1" onmouseover="msgOnmouseover(1)" onmouse
阅读全文
摘要:string str = "http://www.rczjp.cn/A/B/C/index.aspx?cid=11&sid=22"; Regex reg = new Regex(@"(?imn)(?<do>http://[^/]+/)(?<dir>([^/]+/)*([^/.]*$)?)((?<page>[^?.]+\.[^?]+)\?)?(?<par>.*$)"); MatchCollection mc = reg.Matches(str); foreach (Match m in mc) { .
阅读全文
摘要:public static string NoHTML(string Htmlstring) //替换HTML标记 { string pattern = "http://([^\\s]+)\".+?span.+?\\[(.+?)\\].+?>(.+?)<"; Regex reg = new Regex(pattern, RegexOptions.IgnoreCase); //删除脚本 Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script&g
阅读全文
摘要:关于net正则总是看了又忘,忘了又看,一串复杂的东西自己也没看懂,没关系,今天再来开始,一点一点来,不断去做学习名 字空间简介 在名字空间中仅仅包含着6个类和一个定义,它们是:Capture: 包含一次匹配的结果;CaptureCollection: Capture的序列;Group: 一次组记录的结果,由Capture继承而来;Match: 一次表达式的匹配结果,由Group继承而来;MatchCollection: Match的一个序列;MatchEvaluator: 执行替换操作时使用的代理;Regex: 编译后的表达式的实例。 Regex类中还包含一些静态的方法:Escape:...
阅读全文