Regex & BBCode - Perfecting Nested Quote

Posted by Moe on Stack Overflow See other posts from Stack Overflow or by Moe
Published on 2010-05-26T01:09:34Z Indexed on 2010/05/26 1:31 UTC
Read the original article Hit count: 406

Filed under:
|
|
|
|

Hey there,

I'm working on some BBcode for my website.

I've managed to get most of the codes working perfectly, however the [QUOTE] tag is giving me some grief.

When I get something like this:

[QUOTE=1]
[QUOTE=2]
This is a quote from someone else
[/QUOTE]
This is someone else quoting someone else
[/QUOTE]

It will return:

> 1 said:  [QUOTE=2]This is a quote from
> someone else

This is someone else quoting someone else[/QUOTE]

So what is happening is the [/quote] from the nested quote is closing the quote block.

The Regex I am using is:

"[quote=(.*?)\](.*?)\[/quote\]'is"

How can I make it so nested Quotes will appear properly?

Thank you.

© Stack Overflow or respective owner

Related posts about php

Related posts about regex