$format_search = [
/\[QUOTE\](.*?)\[\/QUOTE\]/ig
]
$format_replace = [
'<div class="quote">$1</div>'
]
These are search and replace codes. By using
str = str.replace($format_search[0], $format_replace[0])
I replace tags with html div codes. It works good except quote in a quote. If somebody quotes a quoted text in forum such as
[quote][quote]Hi[/quote] Hello[/quote]
instead of this one:
<div class="quote"><div class="quote">Hi</div> Hello</div>
I get this output:
<div class="quote">[quote]Hi</div> Hello[/quote]
it finds first [/quote] and accept it as a closure for the first quote. How can I make the code search [/quote] from end. Is there any another solution?