摘要:一、组的分类 正则中的组有捕获组和非捕获组,而捕获组又分为普通的捕获组和命名捕获组,分别为 捕获组:(exp) 命名捕获组:(? <name> exp) 非捕获组:(?:exp) 二、组的作用 1、捕获组的作用 捕获组的作用是将正则表达式exp匹配到的内容保存到组里,供以后使用 比如这样一个字符串: <ahref="http://bbs.csdn.net"title="床上等你"> CSDN </a> 我想得到网址,而它符合的规则是在 <a...> 标签内,那就可以这样做 C# code string te
阅读全文
摘要:http://www.cnblogs.com/skyd/archive/2009/04/23/1441696.html
阅读全文
摘要:http://code.google.com/p/zsharedcode/wiki/SideBar?tm=6
阅读全文
摘要:http://www.cnblogs.com/zsxfbj/archive/2011/08/05/2128691.html
阅读全文
摘要:byte[] bytes = encoding.GetBytes(PostStr);string retstr = System.Text.Encoding.UTF8.GetString(bytes);
阅读全文
摘要:string pattenhref = "<a([^>])*>"; string pattenhrefend = "</a([^>])*>"; Regex rg = new Regex(pattenhref, RegexOptions.Multiline | RegexOptions.Singleline); MatchCollection m = rg.Matches(strtext); for (int i = 0; i < m.Count; i++) { MessageBox.Show(m[i].Resul
阅读全文
摘要:http://see.xidian.edu.cn/cpp/html/1439.html
阅读全文
摘要:/// <summary> /// 取得HTML中所有图片的 URL。 /// </summary> /// <param name="sHtmlText">HTML代码</param> /// <returns>图片的URL列表</returns> public static string[] GetHtmlImageUrlList(string sHtmlText) { // 定义正则表达式用来匹配 img 标签 Regex regImg = new Regex(@"<img\b[^
阅读全文
摘要:public static string NoHTML(stringHtmlstring) { //删除脚本 Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase); //删除HTML Htmlstring = Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", ...
阅读全文
摘要:using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Text.RegularExpressions;public part
阅读全文
摘要:简单C#信息采集工具实现最近想整只爬虫玩玩,顺便熟悉下正则表达式。开发环境 vs2008 sql2000实现方法如下1.先抓取网页代码2.通过正则匹配出你需要的内容比如http://www.soso.com/q?w=%C4%E3%BA%C3&pg=1 页面中 搜索结果的标题跟连接地址。具体可以根据你的需要填写合适的地址跟正则。3.把匹配出的内容保存到数据库中。对其中的数据可以根据需要自己进行处理具体实现代码1.读取网页的代码 public static string GetDataFromUrl(string url) { string str = string.Empty; ...
阅读全文
摘要:C#登录采集相关资料大搜集,前一段时间参考了很多文章,记录下来的有点乱,下次需要备用参考,文章内显示http://topic.csdn.net/u/20090929/15/7dd2936e-273f-4b8a-b578-2fd09e2bc191.htmlhttp://blog.hnce.net/post/dotnet_GetInfo_AutoLogin.htmlhttp://www.httpwatch.com/download/C#三种模拟自动登录和提交POST信息的实现方法http://www.diybl.com/course/4_webprogram/asp.net/netjs/20071
阅读全文
摘要:读:TextBox1.Text=File.ReadAllText("d:/b.txt",Encoding.Default);写:File.WriteAllText("d:/a.txt", TextBox1.Text, Encoding.Default);追加:File.AppendAllText("d:/a.txt", TextBox1.Text, Encoding.Default);
阅读全文
摘要:原文地址:http://hi.baidu.com/%CD%F8%CE%A2%C3%F9/blog/item/25ac98287be1d121d52af179.html本人电脑上,codesmith版本:5.2mysql版本:5.1codesmith连接mysql需要下载MySql.Data.dll文件下载地址是http://dev.mysql.com/downloads/connector/net/5.1.html请先注册登录后才能下载mysql-connector-net-5.1.7.zip这个文件,这个文件是解决ado.net连接mysql的,下载后安装它,默认安装就可以了,想换路径看你自
阅读全文
摘要:第一部分:O'Reilly 出版的《C# Cookbook》泛型部分翻译第一回:理解泛型第二回:获取泛型类型和使用相应的泛型版本替换ArrayList第三回:使用相应的泛型版本替换Stack和Queue第四回:链表的实现和可空类型第五回:反转SortedList里的内容第六回:使用泛型创建只读集合及使用相应的泛型版本替换Hashtable第七回:在泛型字典类中使用foreach及泛型约束第八回:初始化泛型类型变量为它们的默认值第二部分:O'Reilly 出版的《Programming C#》第四版泛型部分翻译第一回:泛型的集合接口第二回:泛型约束第三回:泛型List第四回:实现
阅读全文
摘要:例子代码:class Program { static void Main(string[] args) { int obj = 2; Test<int> test = new Test<int>(obj); Console.WriteLine("int:" + test.obj); string obj2 = "hello world"; Test<string> test1 = new Test<string>(obj2); ...
阅读全文
摘要:public string GetUrlDomainName(string url) { //获取域名的正则表达式 string p = @"http://[^\.]*\.(?<domain>[^/|?]*)"; Regex reg = new Regex(p, RegexOptions.IgnoreCase);//不区分大小写匹配 //正则表达式匹配结果 Match m = reg.Match(url); //返回匹配结果值 ...
阅读全文
摘要:bulider.AppendLine("User-Agent: Mozilla/5.0 (Windows NT 6.1; IE 9.0)"); sbSend.Append("User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)\r\n");requestHeaders.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1;
阅读全文
摘要:IE 而IE各个版本典型的userAgent如下: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2) Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Mozilla/4.0 (compatible; MSIE 5.0; Windows NT) 其中,版本号是MSIE之后的数字。 Firefox Firefox几个版本的userAgent大致如下: Mozilla/5.0 (Wi...
阅读全文
摘要:if (webBrowser1.InvokeRequired) { webBrowser1.Invoke(new MethodInvoker(() => { try { ie.IEFlow.Wait(Config.DwddTime); } catch { } })); } else { ie.IEFlow.Wait(Config.DwddTime); }
阅读全文
摘要:public string GetUrlDomainName(string url) { //获取域名的正则表达式 string p = @"http://[^\.]*\.(?<domain>[^/|?]*)"; Regex reg = new Regex(p, RegexOptions.IgnoreCase);//不区分大小写匹配 //正则表达式匹配结果 Match m = reg.Match(url); //返回匹配结果值 return m.Groups["domain"].Value; }获取域名就不说了吧 下面是正则的使用 publi
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;using System.Text.RegularExpressions;namespace rexurl{ class Program { static void Main(string[] args) { string regex = @"(?i)http://(\w+\.){2,3}(com(\.cn)?|cn|net)\b"; string content = "
阅读全文
摘要:数据库里面的是 <font color='ff0000'>最新国内外新闻..... </font> 我要他显示出来是 <font color='ff0000'>最新国内外.(只显示5个字) </font> <font color='ff0000'>这个是不定的,我要的是这个<font color='ff0000'></font>中间只显示5个文字怎么实现呢... --> 转移QQ号:21993961时间:2008-08-27 17:34--&
阅读全文
摘要:两个特定字符串带有符号的;例如"PROMOTEDTYPE":"260","MEMBERID":"24912496","SHOPTYPE":"2","EXLEVEL":"15","PROMOTEDTYPE":"260","MEMBERID":"78912496","SHOPTYPE":"2","EXLEVEL&
阅读全文
摘要:比如:class="g">topic.csdn.net/u/20091018/11/ef331a56-93f ... 2011-3-28 </span> - <a其中以class="g">开头 ;</span> - <a结尾如何获取中间的字符串:topic.csdn.net/u/20091018/11/ef331a56-93f ... 2011-3-28 string str = "class=&
阅读全文
摘要:如题。现有代码如下。只能截取 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); ...
阅读全文
摘要: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...
阅读全文
摘要: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
阅读全文
摘要:public struct Struct_INTERNET_PROXY_INFO { public int dwAccessType; public IntPtr proxy; public IntPtr proxyBypass; }; [DllImport("wininet.dll", SetLastError = true)] private static extern bool InternetSetOption(IntPtr hInternet, int dwOpt...
阅读全文
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;namespace WindowsApplication1{ public partial class AutoDeleteMessageBox : Form { [DllImport...
阅读全文
摘要:事件回调,看一点我的代码 在Form1里面写一个方法,用来修改label 在Form2里面写: public delegate void SetMainFormTopMostHandle(bool topmost); public event SetMainFormTopMostHandle SetMainFormTopMost; 声明一个委托和事件 然后在f2.Show()打开f2之前,加一句: Form2 f2 = new Form2 (); f2.SetMainFormTopMost += new Form2.SetMainFormTopMostHandle(MainForm_SetMa
阅读全文
摘要:window.close();System.Diagnostics.Process[] myProcesses; myProcesses = System.Diagnostics.Process.GetProcessesByName("IEXPLORE"); foreach (System.Diagnostics.Process instance in myProcesses) { instance.CloseMainWindow(); }instance.kill(); Process[] pros = System.Diagnostics.Proce...
阅读全文
摘要:可以实现例如通过应用程序操作google搜索,用户输入要搜索的内容,然后在google中搜索;可以自动点击网页上的按钮等功能 1. 加入对Microsoft Internet Controls的引用; 2. 加入对Microsoft HTML Object Library的引用;(要引入Microsoft.mshtml.dll 地址是C:\Program Files\Microsoft.NET\Primary Interop Assemblies) 3. 通过mshtml.IHTMLDocument2、SHDocVw.InternetExplorer、SHDocVw.ShellWindowsC
阅读全文
摘要:可以实现例如通过应用程序操作google搜索,用户输入要搜索的内容,然后在google中搜索;可以自动点击网页上的按钮等功能 1. 加入对Microsoft Internet Controls的引用; 2. 加入对Microsoft HTML Object Library的引用;(要引入Microsoft.mshtml.dll 地址是C:\Program Files\Microsoft.NET\Primary Interop Assemblies) 3. 通过mshtml.IHTMLDocument2、SHDocVw.InternetExplorer、SHDocVw.ShellWindowsC
阅读全文
摘要://在工程属性中设置“允许不安全代码”为trueusing System;using System.Net;using System.Net.Sockets;using System.Threading;//需要的命名空间不用解释了吧 namespace syn{ public struct ipHeader { public byte ip_verlen; //4位首部长度+4位IP版本号 public byte ip_tos; //8位服务类型TOS public ushort ip_totallength; //16位数据包总长度(字节) public ushort ip_id; ...
阅读全文
摘要:在对数据处理时往往要实现对数据的批量导入功能。一般的处理方法如下1、读入TXT文件的一行2、按照顺序放入到指定的对象(这里用到反射功能)3、根据类中的主键判断是否已经存在在数据库中4、如果存在,则更新,如果不存在则插入。这里每个要导入的类必须实现IPK接口,返回主键信息。判断是否存在使用如下方法://多个参数一定要有别名String sql = "from "+_type +" as o"+ whereClause;//查找IList op = Connect.getSession().Find(sql);其中where字句是根据主键信息生成的字符串。注
阅读全文
摘要:NHibernate学习http://sifang2004.cnblogs.com/archive/2005/09/05/230713.html
阅读全文
摘要:private void ShowOrActiveForm<T>(string FormName) where T : Form, new() { #region Form fm; if (Application.OpenForms[FormName] != null) { fm = Application.OpenForms[FormName]; fm.Activate(); } else { fm = new T(); //fm.MdiParent = this; fm.Show(); } #endregion }
阅读全文
摘要:参照案例下载:/Files/liuxiaojun/LXJ.NHibernate.Demo.rar场景描述:Users,UserProfiles删除一个User时,连带删除此User拥有的ProfileNHibernate的批量删除可以采用两种方式:1、先把要删除的对象查询出来,然后循环对查询出的对象集合进行删除,代码如下:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->session.Delete(exists_user);IList<
阅读全文
摘要:-HQL: Hibernate查询语言 Hibernate配备了一种非常强大的查询语言,这种语言看上去很像SQL。但是不要被语法结构 上的相似所迷惑,HQL是非常有意识的被设计为完全面向对象的查询,它可以理解如继承、多态 和关联之类的概念。 第 15 章 HQL: Hibernate查询语言Hibernate配备了一种非常强大的查询语言,这种语言看上去很像SQL。但是不要被语法结构 上的相似所迷惑,HQL是非常有意识的被设计为完全面向对象的查询,它可以理解如继承、多态 和关联之类的概念。 15.1. 大小写敏感性问题除了Java类与属性的名称外,查询语句对大小写并不敏感。 所以 SeLeCT
阅读全文
摘要:今天为了处理批量数据操作写了个简单的NHibernate helper类,支持同一事务的批量数据处理. 转载自:http://www.cnblogs.com/rayman/archive/2005/03/27/126702.aspxusingSystem; usingSystem.Threading; usingSystem.Collections; usingSystem.Collections.Specialized; usingNullables; usingNullables.NHibernate; usingNHibernate; usingNHibernate.Cfg; na...
阅读全文
摘要:<?xml version="1.0" encoding="utf-8" ?><configuration> <configSections> <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler,NHibernate" requirePermission="false"/> </configSections> &
阅读全文
摘要:Finisar.SQLite.SQLiteConnection情况:我想存储少量的数据,在数据库,2,并且使用nhibernatenhibernate对access的支持算不上好,所以我就选择使用了sqlite,但是同样的代码在ms sql server上能通过但就是就对sqlite通过不过,通过一步,步地跟踪发现sqlite的构造函数是如下的情况public SQLiteDriver() : base("SQLite.NET","Finisar.SQLite.SQLiteConnection","Finisar.SQLite.SQLiteCo
阅读全文
摘要:http://sourceforge.net/projects/nhibernate/files/NHibernate/
阅读全文
摘要:1.NHibernate使用3中框架动态代理方式(1).Castle框架如果使用Castle.DynamicProxy2动态代理,引用NHibernate.ByteCode.Castle.dll程序集并配置proxyfactory.factory_class<property name="proxyfactory.factory_class"> NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle</property>(2).LinFu框架如果使用LinFu
阅读全文
摘要:http://sourceforge.net/projects/sqlite-dotnet2/files/SQLite%20for%20ADO.NET%202.0/
阅读全文
摘要:http://home.cnblogs.com/group/topic/6006.htmlhttp://www.verycd.com/topics/2762344/
阅读全文
摘要:https://community.jboss.org/wiki/DatabasessupportedbyNHibernate?_sscc=thttp://blog.csdn.net/guxianga/article/details/1791195
阅读全文
摘要:第一次实践nh,吧配置中遇到的问题记录一下,手写配置不容易啊,还好有schame.我当时真想暴走了,md整整花了我5个小时才把程序跑起来。先说下我的环境vs2008 + sqllite1. mapping 文件 设置 生成操作-》嵌入的资源 异常内容 :NHibernate.MappingException: An association from the table Orders refers to an unmapped class: NHibernate.Domain.Entities.Customer2. hibernate.cfg.xml 设置 生成操作-》嵌入的资源 输出目录-》.
阅读全文
摘要:NHibernate这个我一直很纠结,以前一直认为依赖框架不好,而且运行速度也不快,直到最近做的烦了,速度越来越受不了了,想想还是找个好用的框架吧,就学学NHIBERnate吧NHibernate之旅系列文章导航http://www.cnblogs.com/lyj/archive/2008/10/30/1323099.html
阅读全文