$str = 'This is a [a href=xxx]test ![/a], show photos , now [img href=xxx]';//把上面的替换成下面的 , 也就是替换掉[a][b][img]类型的标签$str = '<b>This is a <a href="xxx">test !</a></b>, show photos , now <img href="xxx" />';
调试欢乐多
$b=ereh_replace("[","<",$str);
$a=ereg_replace("]",">",$b);
echo $a;
没你说那么简单吧,如果单独一个[a]都被你替换了成<a>了
$str = 'This is a [a href=xxx]test ![/a], show photos , now [img href=xxx]';
$str = preg_replace('|\[([^]]*)\]|', '<$1>', $str);
echo $str;
$str = 'This is a [a href=xxx]test ![/a], show photos , now [img href=xxx]';
preg_replace("/\[([^\]]+?)((=)(.*?))?\]/","<$1$3\"$4\"",$str);
echo $str;
很多很多
搜了一堆垃圾出来, 那些ubb的实现方法大都是把方括号换成花括号, 不要求正则上配置,连单独的方括号也被替换了, 又些打包成非常臃肿的类, 我想搞个轻量的函数或方法来解决, 而且要正则要配置得正确