zoukankan      html  css  js  c++  java
  • 自动识别超链接

    public string Url_Rewrite(string Text)
        {
            //用?正?则?表?达?式?识?别?URL超?链?接?
            Regex UrlRegex = new Regex(@"(http:\/\/([\w.]+\/?)\S*)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
            //进?规?则?查?询?
            //Url
            MatchCollection matches = UrlRegex.Matches(Text);
            foreach (Match match in matches)
            {
                Text = Text.Replace(match.Value, string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", match.Value, match.Value));
            }
            //用?正?则?表?达?式?识?别?Email地?址?
            Regex EmailRegex = new Regex(@"([a-zA-Z_0-9.-]+\@[a-zA-Z_0-9.-]+\.\w+)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
            matches = EmailRegex.Matches(Text);
            foreach (Match match in matches)
            {
                Text = Text.Replace(match.Value, string.Format("<a href=mailto:{0}>{1}</a>", match.Value, match.Value));
            }
            return Text;
        }
    A
  • 相关阅读:
    cJson
    STemWin
    TEA通讯加密
    stm32串口收发导致的死机
    C语言版数据结构算法
    FIFO
    IAP远程在线升级
    LWIP
    电能计量芯片
    单片机里的堆栈
  • 原文地址:https://www.cnblogs.com/shuyu/p/1704724.html
Copyright © 2011-2022 走看看