【发布时间】:2014-08-20 18:19:09
【问题描述】:
正则表达式:http://regex101.com/r/uO6jQ3/1
字符串:
[quote]something [quote]something else[/quote] some text here[/quote]
当前正则表达式匹配的内容:
$matches[6][0]:[quote]something [quote]something else[/quote]
应该匹配什么:
$matches[6][0]:[quote]something [quote]something else[/quote] some text here[/quote]
$matches[6][1]:[quote]something else[/quote]
【问题讨论】:
-
不要使用正则表达式解析 HTML/BBCode/XML。这是禁止的。
-
对不起,正则表达式不能那样工作。
-
@hsz:不被禁止,但绝对“无法处理所有可能的 bbcode 标记组合”。
-
小心尝试使用正则表达式解析嵌套标签。可以召唤unholy ponies
-
你想做什么,递归解析嵌套的
[quote][/quote]沿途取出内容,构建哈希树还是?同时检查错误?当然可以使用正则表达式来完成。