zoukankan      html  css  js  c++  java
  • url 自动加入链接

     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
  • 相关阅读:
    WCF上传下载文件
    WCF使用相关
    .net WCF WF4.5 状态机、书签与持久化
    .net WCF WF4.5
    CSS小东西
    asp.net mvc导出execl_转载
    winform自定义控件开发
    html问题汇总
    工作中的小东西
    jQuery事件
  • 原文地址:https://www.cnblogs.com/suneryong/p/747126.html
Copyright © 2011-2022 走看看