對(duì)C#中正則表達(dá)式的一些解讀和總結(jié)(6)_.Net教程
推薦:從Internet上抓取指定URL的源碼的方案(C#)引言: 在做無(wú)線項(xiàng)目的時(shí)候,與通訊公司的數(shù)據(jù)通訊有一部分是通過(guò)XML交互的,所以必須要?jiǎng)討B(tài)抓取通訊公司提供的固定的Internet上的數(shù)據(jù),便研究了一下如何抓取固定url上的數(shù)據(jù),現(xiàn)與
string t8 = @"
/*
* 傳統(tǒng)風(fēng)格的注釋
*/
";
string p8 = @"
/\* # 匹配注釋開(kāi)始的定界符
.*? # 匹配注釋
\*/ # 匹配注釋結(jié)束定界符
";
string r8 = Regex.Replace(t8, p8, "", "xs");
刪除字符串中開(kāi)始和結(jié)束處的空格
string t9a = " leading";
string p9a = @"^\s ";
string r9a = Regex.Replace(t9a, p9a, "");
string t9b = "trailing ";
string p9b = @"\s $";
string r9b = Regex.Replace(t9b, p9b, "");
在字符\后添加字符n,使之成為真正的新行
string t10 = @"\ntest\n";
string r10 = Regex.Replace(t10, @"\\n", "\n");
轉(zhuǎn)換IP地址
string t11 = "55.54.53.52";
string p11 = "^"
@"([01]?\d\d|2[0-4]\d|25[0-5])\."
@"([01]?\d\d|2[0-4]\d|25[0-5])\."
@"([01]?\d\d|2[0-4]\d|25[0-5])\."
@"([01]?\d\d|2[0-4]\d|25[0-5])"
"$";
Match m11 = Regex.Match(t11, p11);
刪除文件名包含的路徑
string t12 = @"c:\file.txt";
string p12 = @"^.*\\";
string r12 = Regex.Replace(t12, p12, "");
分享:ASP.NET對(duì)IIS中的虛擬目錄進(jìn)行操作//假如虛擬目錄名為"Webtest",先在項(xiàng)目中引用 //System.DirectoryServices.dll,再 using System.DirectoryServices; protected System.DirectoryServices.DirectoryEntry di
- asp.net如何得到GRIDVIEW中某行某列值的方法
- .net SMTP發(fā)送Email實(shí)例(可帶附件)
- js實(shí)現(xiàn)廣告漂浮效果的小例子
- asp.net Repeater 數(shù)據(jù)綁定的具體實(shí)現(xiàn)
- Asp.Net 無(wú)刷新文件上傳并顯示進(jìn)度條的實(shí)現(xiàn)方法及思路
- Asp.net獲取客戶端IP常見(jiàn)代碼存在的偽造IP問(wèn)題探討
- VS2010 水晶報(bào)表的使用方法
- ASP.NET中操作SQL數(shù)據(jù)庫(kù)(連接字符串的配置及獲取)
- asp.net頁(yè)面?zhèn)髦禍y(cè)試實(shí)例代碼
- DataGridView - DataGridViewCheckBoxCell的使用介紹
- asp.net中javascript的引用(直接引入和間接引入)
- 三層+存儲(chǔ)過(guò)程實(shí)現(xiàn)分頁(yè)示例代碼
- 相關(guān)鏈接:
- 教程說(shuō)明:
.Net教程-對(duì)C#中正則表達(dá)式的一些解讀和總結(jié)(6)
。