1.替換目標字符串中的url 成為超鏈接
using System;
using System.Text.RegularExpressions;
namespace ArLi.CommonPrj
{
public class ReplaceLink
{
public ReplaceLink()
{
}
/// <summary>替換目標字符串中的url 成為超鏈接</summary>
/// <param name="myStr">要替換的字符串</param>
public static string rpOf(string myStr) {
myStr += " ";
Regex myre = new Regex(@"http://\S+ ", RegexOptions.IgnoreCase);
MatchCollection mclist = myre.Matches(myStr);
foreach (Match m in mclist){
myStr = myStr.Replace(m.Value,"<a href=\"" + m.Value.Remove(m.Value.Length-1,1) + "\"> ");
}
return myStr.Remove(myStr.Length -1,1);
}
}
}