Javascript Not Parsing Nested Bbcode

一个人想着一个人 提交于 2019-12-02 05:18:38

Three solutions:

  1. Write a parser. This will produce the best solution but takes a non-trivial amount of effort.

  2. Find a BBCode parsing library. Probably as good as #1 in quality and substantially easier.

  3. Add a negative lookahead to the inside of each tag regex and continuously apply until no match. E.g.:

    \[quote\]((?:[^](?!\[quote\]))*?)\[\/quote\]
    

    This will capture the inner quote, then once its replaced, the outer one. Not nearly as clean as the other two but probably the quickest fix.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!