public static string Auto(string str)
//========================//
// www.
// http://
// ftp://
//
[email protected] // mms://
//========================//
{
Reg = new Regex("([^\\]=>])(http://[A-Za-z0-9\\./=\\?%\\-&_~`@':+!]+)");
str = Reg.Replace(str,"$1<a href=\"$2\" target=\"_blank\">$2</a>");
Reg = new Regex("^(http://[A-Za-z0-9\\./=\\?%\\-&_~`@':+!]+)");
str = Reg.Replace(str,"<a href=\"$1\" target=\"_blank\">$1</a>");
Reg = new Regex("(http://[A-Za-z0-9\\./=\\?%\\-&_~`@':+!]+)$");
str = Reg.Replace(str,"<a href=\"$1\" target=\"_blank\">$1</a>");
Reg = new Regex("([^\\]=>])(ftp://[A-Za-z0-9\\./=\\?%\\-&_~`@':+!]+)");
str = Reg.Replace(str,"$1<a href=\"$2\" target=\"_blank\">$2</a>");
Reg = new Regex("^(ftp://[A-Za-z0-9\\./=\\?%\\-&_~`@':+!]+)");
str = Reg.Replace(str,"<a href=\"$1\" target=\"_blank\">$1</a>");
Reg = new Regex("(ftp://[A-Za-z0-9\\./=\\?%\\-&_~`@':+!]+)$");
str = Reg.Replace(str,"<a href=\"$1\" target=\"_blank\">$1</a>");
Reg = new Regex("([^\\]=>])(mms://[A-Za-z0-9\\./=\\?%\\-&_~`@':+!]+)");
str = Reg.Replace(str,"$1<a href=\"$2\" target=\"_blank\">$2</a>");
Reg = new Regex("^(mms://[A-Za-z0-9\\./=\\?%\\-&_~`@':+!]+)");
str = Reg.Replace(str,"<a href=\"$1\" target=\"_blank\">$1</a>");
Reg = new Regex("(mms://[A-Za-z0-9\\./=\\?%\\-&_~`@':+!]+)$");
str = Reg.Replace(str,"<a href=\"$1\" target=\"_blank\">$1</a>");
Reg = new Regex("([a-z0-9_A-Z\\-\\.]{1,20})@([a-z0-9_\\-]{1,15})\\.([a-z]{2,4})");
str = Reg.Replace(str,"<a href=\"mailto:$1@$2.$3\" target=\"_blank\">$1@$2.$3</a>");
Reg = new Regex("([^/])(www.[A-Za-z0-9\\./=\\?%\\-&_~`@':+!]+)");
str = Reg.Replace(str,"$1<a href=\"http://$2\" target=\"_blank\">$2</a>");
Reg = new Regex("^(www.[A-Za-z0-9\\./=\\?%\\-&_~`@':+!]+)");
str = Reg.Replace(str,"<a href=\"http://$1\" target=\"_blank\">$1</a>");
Reg = new Regex("(www.[A-Za-z0-9\\./=\\?%\\-&_~`@':+!]+)$");
str = Reg.Replace(str,"<a href=\"http://$1\" target=\"_blank\">$1</a>");
return str;
}
本文地址:http://com.8s8s.com/it/it42437.htm