2012年5月18日

求一个截取字符的正则表达式

摘要: 数据库里面的是 <font color='ff0000'>最新国内外新闻..... </font> 我要他显示出来是 <font color='ff0000'>最新国内外.(只显示5个字) </font> <font color='ff0000'>这个是不定的,我要的是这个<font color='ff0000'></font>中间只显示5个文字怎么实现呢... --> 转移QQ号:21993961时间:2008-08-27 17:34--& 阅读全文

posted @ 2012-05-18 11:08 HOT SUMMER 阅读(940) 评论(0) 推荐(0)

正则表达式截取两个特定字符串之间的字符串

摘要: 两个特定字符串带有符号的;例如"PROMOTEDTYPE":"260","MEMBERID":"24912496","SHOPTYPE":"2","EXLEVEL":"15","PROMOTEDTYPE":"260","MEMBERID":"78912496","SHOPTYPE":"2","EXLEVEL& 阅读全文

posted @ 2012-05-18 11:05 HOT SUMMER 阅读(38189) 评论(0) 推荐(2)

正则 截取固定开头结尾字符串中间的字符串

摘要: 比如:class=&quot;g&quot;&gt;topic.csdn.net/u/20091018/11/ef331a56-93f ... 2011-3-28 &lt;/span&gt; - &lt;a其中以class=&quot;g&quot;&gt;开头 ;&lt;/span&gt; - &lt;a结尾如何获取中间的字符串:topic.csdn.net/u/20091018/11/ef331a56-93f ... 2011-3-28 string str = "class=& 阅读全文

posted @ 2012-05-18 11:02 HOT SUMMER 阅读(6457) 评论(0) 推荐(1)

C#如何用正则表达式截取https和带端口的域名

摘要: 如题。现有代码如下。只能截取 http://www.baidu.com的 www.baidu.com当域名为https://www.baidu.com 或者为 http://www.baidu.com:8080 时 则无法正确读取。。求高手给去能截取这样格式的代码 Thanks! string p = @"http://[^\.]*\.(?<domain>[^\.]*)"; Regex reg = new Regex(p, RegexOptions.IgnoreCase); Match m = reg.Match(HostUrl); ... 阅读全文

posted @ 2012-05-18 10:57 HOT SUMMER 阅读(3034) 评论(0) 推荐(0)

<<字符串高级截取和统计>>一文的C#正则实现

摘要: using System;using System.Text.RegularExpressions;namespace SubStringDemo{ class Program { static void Main(string[] args) { string source = "123412355123559912323399"; string destString = "123"; Console.WriteLine("SubString count:" + SubString(so... 阅读全文

posted @ 2012-05-18 10:53 HOT SUMMER 阅读(238) 评论(0) 推荐(0)

用于测试的字符串

摘要: 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> 阅读全文

posted @ 2012-05-18 10:51 HOT SUMMER 阅读(229) 评论(0) 推荐(0)

抓取html 写正则

摘要: 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 获取网页编码 /... 阅读全文

posted @ 2012-05-18 10:49 HOT SUMMER 阅读(686) 评论(0) 推荐(0)

正则截取内容

摘要: 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; } 阅读全文

posted @ 2012-05-18 10:36 HOT SUMMER 阅读(383) 评论(0) 推荐(0)

用C#和正则表达式截取html代码

摘要: 【IT168技术文档】如何使用C#和正则表达式截取html代码呢,如何处理html代码中的\r\n这样的字符呢,下面我们来一起研究一下,先从截取目标开始。一、代码说明 1.以下html表示收到的3个组的信息,如果含有"unread.gif"表示未读消息,否则表示已读信息。 2.截取未读消息和已读消息的条数和theUrl 3.要将未读信息和已读信息分开放入两个组里。 <div class="dxx_of" id="message1" onmouseover="msgOnmouseover(1)" onmouse 阅读全文

posted @ 2012-05-18 10:34 HOT SUMMER 阅读(1772) 评论(0) 推荐(0)

C#正则截取URL网址字符串

摘要: 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) { . 阅读全文

posted @ 2012-05-18 10:31 HOT SUMMER 阅读(1891) 评论(0) 推荐(0)

调用下面的方法屏蔽所有html标签提取文本

摘要: 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 阅读全文

posted @ 2012-05-18 10:28 HOT SUMMER 阅读(922) 评论(0) 推荐(0)

导航