ubb替换
ubb正则替换
<?php
$string=":'( 没女朋友的孩纸伤不起
[b]嫁给我呗[/b]
[i]给我生个娃[/i]
[u]俺给你买辆车,先去摇号去吧[/u]
[size=7]再来看看[/size]
[color=Red]伤不起[/color]
[img]http://127.0.0.1/backup/bbs/images/default/logo.gif[/img]
[qq]1378353651[/qq]";
$pattern=array(
'/\[b\](.*?)\[\/b\]/i',
'/\[i\](.*?)\[\/i\]/i',
'/\[u\](.*?)\[\/u\]/i',
'/\[size=(\d)\](.*?)\[\/size\]/',
'/\[color=(\w+)\](.*?)\[\/color\]/',
'/\[img\](.*?)\[\/img\]/',
'/\[qq\](\d+)\[\/qq\]/',
'/:\'\(/',
);
$replace=array(
'<b>\\1</b>',
'<i>\\1</i>',
'<u>\\1</u>',
'<font size="\\1">\\2</font>',
'<font color="\\1">\\2</font>',
'<img src="\\1" />',
'<a href="http://wpa.qq.com/msgrd?V=1&Uin=\\1&Site=[35班好多好多帅锅哦]&Menu=yes" target="_blank"><img src="http://wpa.qq.com/pa?p=1:\\1:1" border="0"></a>',
'<img src=cry.gif />',
);
$str=preg_replace($pattern,$replace,$string);
echo $str;
?>