2
任何人都可以帮我解决这个问题吗?preg_replace for [list] [*] [/ list]
我使用的BBcode为我的网站,但在文本编辑器中我发现一个问题:
的UI
[list]
[*]Lorem Ipsum
[/list]
[list=1]
[*]Lorem Ispum
[/list]
我用这脚本:
$filter = preg_replace("#[[]list[]](.*)[[]/list[]]#","<ul>$1</ul>",$filter);
$filter = preg_replace("#[[]list=([^0-9][]](.*)[[]/list[]]#","<ol start=$1>$2</ul>",$filter);
$filter = preg_replace("#[*](.*)#","<li>$1</li>",$filter);
我得到的问题,此脚本 - 它不能使用,因为脚本found symbol after [list]
,它不能执行下一条语句
preg_replace("#[[]list[]] (.*) [[]/list[]]#","<ul>$1</ul>",$filter);
[list]
[*] Lorem Ipsum --- Stuck In Long Space
[/list]
请在[字符类]读了(http://www.regular-expressions.info/charclass.html)。还可以使用'#s'修饰符来使'。*'匹配换行符。但也考虑搜索现成的bbcode /无论转换器,因为你的编码尝试有更多的缺陷。 – mario
您可能还想看看BBCode模块:http://php.net/manual/en/book.bbcode.php –