對C#中正則表達式的一些解讀和總結(jié)(7)_.Net教程
推薦:從Internet上抓取指定URL的源碼的方案(C#)引言: 在做無線項目的時候,與通訊公司的數(shù)據(jù)通訊有一部分是通過XML交互的,所以必須要動態(tài)抓取通訊公司提供的固定的Internet上的數(shù)據(jù),便研究了一下如何抓取固定url上的數(shù)據(jù),現(xiàn)與
聯(lián)接多行字符串中的行
string t13 = @"this is
a split line";
string p13 = @"\s*\r?\n\s*";
string r13 = Regex.Replace(t13, p13, " ");
提取字符串中的所有數(shù)字
string t14 = @"
test 1
test 2.3
test 47
";
string p14 = @"(\d \.?\d*|\.\d )";
MatchCollection mc14 = Regex.Matches(t14, p14);
找出所有的大寫字母
string t15 = "This IS a Test OF ALL Caps";
string p15 = @"(\b[^\Wa-z0-9_] \b)";
MatchCollection mc15 = Regex.Matches(t15, p15);
找出小寫的單詞
string t16 = "This is A Test of lowercase";
string p16 = @"(\b[^\WA-Z0-9_] \b)";
MatchCollection mc16 = Regex.Matches(t16, p16);
找出第一個字母為大寫的單詞
string t17 = "This is A Test of Initial Caps";
string p17 = @"(\b[^\Wa-z0-9_][^\WA-Z0-9_]*\b)";
MatchCollection mc17 = Regex.Matches(t17, p17);
找出簡單的HTML語言中的鏈接
string t18 = @"
<html>
<a href=""first.htm"">first tag text</a>
<a href=""next.htm"">next tag text</a>
</html>
";
string p18 = @"<A[^>]*?HREF\s*=\s*[""']?" @"([^'"" >] ?)[ '""]?>";
MatchCollection mc18 = Regex.Matches(t18, p18, "si");
分享:ASP.NET對IIS中的虛擬目錄進行操作//假如虛擬目錄名為"Webtest",先在項目中引用 //System.DirectoryServices.dll,再 using System.DirectoryServices; protected System.DirectoryServices.DirectoryEntry di
- asp.net如何得到GRIDVIEW中某行某列值的方法
- .net SMTP發(fā)送Email實例(可帶附件)
- js實現(xiàn)廣告漂浮效果的小例子
- asp.net Repeater 數(shù)據(jù)綁定的具體實現(xiàn)
- Asp.Net 無刷新文件上傳并顯示進度條的實現(xiàn)方法及思路
- Asp.net獲取客戶端IP常見代碼存在的偽造IP問題探討
- VS2010 水晶報表的使用方法
- ASP.NET中操作SQL數(shù)據(jù)庫(連接字符串的配置及獲取)
- asp.net頁面?zhèn)髦禍y試實例代碼
- DataGridView - DataGridViewCheckBoxCell的使用介紹
- asp.net中javascript的引用(直接引入和間接引入)
- 三層+存儲過程實現(xiàn)分頁示例代碼
- 相關(guān)鏈接:
- 教程說明:
.Net教程-對C#中正則表達式的一些解讀和總結(jié)(7)
。