url 自动加入链接
生活随笔
收集整理的這篇文章主要介紹了
url 自动加入链接
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
?1string?strContent?=?TextBox1.Text;
?2
?3????????????//(http:\/\/([\w.]+\/?)\S*)
?4????????????//http://([\w-]+\.)+[\w-]+(/[\w-?./?%&=]*)?
?5
?6????????????//都是匹配url的正則
?7????????????Regex?urlregex?=?new?Regex(@"(http:\/\/([\w.]+\/?)\S*)",RegexOptions.IgnoreCase|?RegexOptions.Compiled);
?8????????????
?9????????????System.Text.RegularExpressions.MatchCollection?match=urlregex.Matches(strContent);
10????????
11????????????for(int?i=0;i<match.Count;i++)
12????????????{
13????????????????//"<a?href=\"\"?target=\"_blank\"></a>");
14????????????????strContent?=?strContent.Replace(match[i].Value,"<a?href=\""+match[i].Value+"\">"+match[i].Value+"</a>");
15????????????}
16????????????Label1.Text+=?"<br>"+strContent;
17
?2
?3????????????//(http:\/\/([\w.]+\/?)\S*)
?4????????????//http://([\w-]+\.)+[\w-]+(/[\w-?./?%&=]*)?
?5
?6????????????//都是匹配url的正則
?7????????????Regex?urlregex?=?new?Regex(@"(http:\/\/([\w.]+\/?)\S*)",RegexOptions.IgnoreCase|?RegexOptions.Compiled);
?8????????????
?9????????????System.Text.RegularExpressions.MatchCollection?match=urlregex.Matches(strContent);
10????????
11????????????for(int?i=0;i<match.Count;i++)
12????????????{
13????????????????//"<a?href=\"\"?target=\"_blank\"></a>");
14????????????????strContent?=?strContent.Replace(match[i].Value,"<a?href=\""+match[i].Value+"\">"+match[i].Value+"</a>");
15????????????}
16????????????Label1.Text+=?"<br>"+strContent;
17
轉(zhuǎn)載于:https://www.cnblogs.com/suneryong/archive/2007/05/15/747126.html
總結(jié)
以上是生活随笔為你收集整理的url 自动加入链接的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SQL server 200 安装问题!
- 下一篇: 通过DataTable导出Excel