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