I have coded a Javascript bbcode similar to the one I\'m using to write this message. It also incorporates a live preview box like the one I see below. The only problem I\'m fac
Three solutions:
Write a parser. This will produce the best solution but takes a non-trivial amount of effort.
Find a BBCode parsing library. Probably as good as #1 in quality and substantially easier.
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.