ASP实现网址的自动识别
类别: ASP教程
public static string Auto(string str)
//========================//
// www.
// http://
// ftp://
// xx@xx.xx
// 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;
}
//========================//
// www.
// http://
// ftp://
// xx@xx.xx
// 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;
}
- 上一篇: ASP类编写详细说明
- 下一篇: GOOGLE PR值查询程序
-= 资 源 教 程 =-
文 章 搜 索