留言版中插入图片链接 http://zwills.crcoo.com/mikespook/softlist.asp?id=68UBB 代码~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 UBB替换代码~~~function h2t($d){ $d=str_replace("<","<",$d); $d=str_replace(">",">",$d); $d=str_replace("|","│",$d); $d=str_replace("\r","",$d); $d=str_replace("\t","",$d); $d=str_replace("\n","<br>",$d); $d=str_replace(" "," ",$d); $pattern = array( "/\[b\](.+?)\[\/b\]/is", "/\[i\](.+?)\[\/i\]/is", "/\[u\](.+?)\[\/u\]/is", "/\[font=([^\[]*)\](.+?)\[\/font\]/is", "/\[color=([#0-9a-z]{1,10})\](.+?)\[\/color\]/is", "/\[size=([0-9]{1,2})\](.+?)\[\/size\]/is", "/\[email=([^\[]*)\](.+?)\[\/email\]/is", "/\[email\]([^\[]*)\[\/email\]/is", "/\[url=([^\[]*)\](.+?)\[\/url\]/is", "/\[url\]www\.([^\[]*)\[\/url\]/is", "/\[url\]([^\[]*)\[\/url\]/is", "/\[fly\](.+?)\[\/fly\]/is", "/\[move\](.+?)\[\/move\]/is", "/\[align=(left|center|right)\](.+?)\[\/align\]/is", "/\[shadow=([#0-9a-z]{1,10})\,([0-9]{1,3})\,([0-9]{1,2})\](.+?)\[\/shadow\]/is", "/\[glow=([#0-9a-z]{1,10})\,([0-9]{1,2})\](.+?)\[\/glow\]/is", "/\[code\](.+?)\[\/code\]/is", "/\[list\](.+?)\[\/list\]/is", "/\[list=([aA1iI])\](.+?)\[\/list\]/is", "/\[\*\](.*?)/i", ); $replacement = array( "<b>\\1</b>", "<i>\\1</i>", "<u>\\1</u>", "<font face=\"\\1\">\\2</font>", "<font color=\"\\1\">\\2</font>", "<font size=\"\\1\">\\2</font>", "<a href=\"mailto:\\1\">\\2</a>", "<a href=\"mailto:\\1\">\\1</a>", "<a href=\"\\1\" target=_blank>\\2</a>", "<a href=\"http://www.\\1\" target=_blank>\\1</a>", "<a href=\"\\1\" target=_blank>\\1</a>", "<marquee width=90% behavior=alternate scrollamount=3>\\1</marquee>", "<marquee scrollamount=3>\\1</marquee>", "<div align=\\1>\\2</div>", "<table width=*><tr><td style=\"filter:shadow(color=\\1, direction=\\2 ,strength=\\3)\">\\4</td></tr></table>", "<table width=*><tr><td style=\"filter:glow(color=\\1, strength=\\2)\">\\3</td></tr></table>", "<blockquote><b>代码:</b><hr color=#990000><font face='Courier New'>\\1</font><hr color=#990000></blockquote>", "<ul>\\1</ul>", "<ol type=\\1>\\2</ol>", "<li>\\1</li>" ); $d = preg_replace($pattern,$replacement,$d); $d = preg_replace("/\[img\]\s*(\S+?)\s*\[\/img\]/is","<a href=\\1 target=_blank title=\"贴图:点击放大查看\"><img src=\\1 border=0 onload=\"javascript:if(this.width>500)this.width=300\"></a>",$d); return $d;} 只是一个函数而已~~~比如你的留言板要插入图片~使用UBB代码~~~然后留言板就有图片显示~~~$str="留言";h2t($str)返回的就是转换后的~ HOHO,这个我倒是知道~只是想知道这个函数这么写什么意思?正则? 是正则表达式~~~用 $replacement 中对应项替换 $pattern 中的内容。这样就可以实现UBB代码到HTML代码的转换~~ ASPif xxx then response.write ""end if 能不能查找数据库 条件是一个字段包含某一个数 并且不包含另外一个数 【求助】正则获取第一行的内容 如何打开80端口? 我用php excelreader读取xls文件,显示的文件是乱码。编码一致也是这样 [模式匹配]文件操作 语言选择页面 怎么制作 pear 里的joinAdd()咋个用? 成都易喜数据科技有限公司诚聘PHP程序员 在LINUX环境下,如果安装PHP的MBSTRING模块 Linux高手必备! 用PHP写一个产品发布系统要多长时间,多少钱? 想接受挑战的朋友进来看看~~
$d=str_replace("<","<",$d);
$d=str_replace(">",">",$d);
$d=str_replace("|","│",$d);
$d=str_replace("\r","",$d);
$d=str_replace("\t","",$d);
$d=str_replace("\n","<br>",$d);
$d=str_replace(" "," ",$d);
$pattern = array(
"/\[b\](.+?)\[\/b\]/is",
"/\[i\](.+?)\[\/i\]/is",
"/\[u\](.+?)\[\/u\]/is",
"/\[font=([^\[]*)\](.+?)\[\/font\]/is",
"/\[color=([#0-9a-z]{1,10})\](.+?)\[\/color\]/is",
"/\[size=([0-9]{1,2})\](.+?)\[\/size\]/is",
"/\[email=([^\[]*)\](.+?)\[\/email\]/is",
"/\[email\]([^\[]*)\[\/email\]/is",
"/\[url=([^\[]*)\](.+?)\[\/url\]/is",
"/\[url\]www\.([^\[]*)\[\/url\]/is",
"/\[url\]([^\[]*)\[\/url\]/is",
"/\[fly\](.+?)\[\/fly\]/is",
"/\[move\](.+?)\[\/move\]/is",
"/\[align=(left|center|right)\](.+?)\[\/align\]/is",
"/\[shadow=([#0-9a-z]{1,10})\,([0-9]{1,3})\,([0-9]{1,2})\](.+?)\[\/shadow\]/is",
"/\[glow=([#0-9a-z]{1,10})\,([0-9]{1,2})\](.+?)\[\/glow\]/is",
"/\[code\](.+?)\[\/code\]/is",
"/\[list\](.+?)\[\/list\]/is",
"/\[list=([aA1iI])\](.+?)\[\/list\]/is",
"/\[\*\](.*?)/i",
);
$replacement = array(
"<b>\\1</b>",
"<i>\\1</i>",
"<u>\\1</u>",
"<font face=\"\\1\">\\2</font>",
"<font color=\"\\1\">\\2</font>",
"<font size=\"\\1\">\\2</font>",
"<a href=\"mailto:\\1\">\\2</a>",
"<a href=\"mailto:\\1\">\\1</a>",
"<a href=\"\\1\" target=_blank>\\2</a>",
"<a href=\"http://www.\\1\" target=_blank>\\1</a>",
"<a href=\"\\1\" target=_blank>\\1</a>",
"<marquee width=90% behavior=alternate scrollamount=3>\\1</marquee>",
"<marquee scrollamount=3>\\1</marquee>",
"<div align=\\1>\\2</div>",
"<table width=*><tr><td style=\"filter:shadow(color=\\1, direction=\\2 ,strength=\\3)\">\\4</td></tr></table>",
"<table width=*><tr><td style=\"filter:glow(color=\\1, strength=\\2)\">\\3</td></tr></table>",
"<blockquote><b>代码:</b><hr color=#990000><font face='Courier New'>\\1</font><hr color=#990000></blockquote>",
"<ul>\\1</ul>",
"<ol type=\\1>\\2</ol>",
"<li>\\1</li>"
);
$d = preg_replace($pattern,$replacement,$d);
$d = preg_replace("/\[img\]\s*(\S+?)\s*\[\/img\]/is","<a href=\\1 target=_blank title=\"贴图:点击放大查看\"><img src=\\1 border=0 onload=\"javascript:if(this.width>500)this.width=300\"></a>",$d);
return $d;
}
h2t($str)返回的就是转换后的~
response.write ""
end if