#region
静态方法:提取字符串中的网址,自动加上链接
/// <summary>
/// 静态方法:提取字符串中的网址,自动加上链接
/// </summary>
/// <param name="_Cont"></param>
/// <returns></returns>
public static string String_UrlAddLink( string _Cont)
{
string StrRegex = @" (http://)?([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)? " ;
Regex R = new Regex(StrRegex, RegexOptions.IgnoreCase);
_Cont = Regex.Replace(_Cont, StrRegex, " <a href=\ " http: // $0\">$0</a>");
_Cont = _Cont.Replace( " http://http:// " , " http:// " );
return _Cont;
}
#endregion
/// <summary>
/// 静态方法:提取字符串中的网址,自动加上链接
/// </summary>
/// <param name="_Cont"></param>
/// <returns></returns>
public static string String_UrlAddLink( string _Cont)
{
string StrRegex = @" (http://)?([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)? " ;
Regex R = new Regex(StrRegex, RegexOptions.IgnoreCase);
_Cont = Regex.Replace(_Cont, StrRegex, " <a href=\ " http: // $0\">$0</a>");
_Cont = _Cont.Replace( " http://http:// " , " http:// " );
return _Cont;
}
#endregion