public string ConvertUrlsToLinks(string msg)
{
string newMsg = "";
string regex = @"((www\.|(http|https|ftp|news|file)+\:\/\/)[_.a-z0-9-]+\.[a-z0-9\/_:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])";
Regex r = new Regex(regex, RegexOptions.IgnoreCase);
newMsg = r.Replace(msg, "$1").Replace("href=\"www", "href=\"http://www");
string emailRegex = @"(([a-zA-Z0-9_\-\.]+@)[_.a-z0-9-]+\.[a-z0-9\/_:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])";
Regex r2 = new Regex(emailRegex, RegexOptions.IgnoreCase);
newMsg = r2.Replace(newMsg, "$1");
return newMsg;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment