我想转:
[quote]Hello![/quote]
进入:
<div class="quoted-text">Hello!</div>
这段代码是我最接近工作的代码:
var r = new Regex(@"\[quote\]([^\]]+)\[\/quote\]", RegexOptions.Multiline | RegexOptions.IgnoreCase);
rawComment = r.Replace(rawComment, "<div class=\"quoted-text\">$1</div>");
但是,对于嵌套引号,它不会正确出现。它似乎只转换最里面的报价。一个测试用例是:
[quote]
test
[quote]
nest
[quote]
nest
[/quote]
[/quote]
[/quote]
结果如下:
[quote]
test
[quote]
nest
<div class="quoted-text">
nest
</div>
[/quote]
[/quote]
谁能告诉我如何按预期进行这项工作?