Ik ben bezig om een ubb parser te maken zodat hij de quote tages netjes omzet. Nu is de bedoeling dat hij ook de quote in een quote kan pakken. Dus [ quote ]hallo[ quote ]hallo2[/ quote ][/ quote ] (expres even met spaties vanwege de parser hier, wat niks helpt dus;))

Om dit te bereiken gebruik ik:

<?php
$string = preg_replace('#\[quote\](.+)\[/quote\]#siU', '<strong>QUOTE:</strong><div class="quote">\\1</div>', $string);

while ( preg_match('#\[quote\](.+)\[/quote\]#siU', $string) == 1 )
{
$string = preg_replace('#\[quote\](.+)\[/quote\]#siU', '<br><strong>QUOTE:</strong><div class="quote">\\1</div>', $string);
}
?>

En dit werkt perfect alleen zou ik ook graag de naam van de geqoute persoon erbij zetten voor de duidelijkheid. Daarvoor zat ik zelf te denken aan:

<?php
$string = preg_replace('#\[quote=(.+?)\](.+?)\[/quote\]#siU', '<strong>QUOTE:\\1</strong><div class="quote">\\2</div>', $string);

while ( preg_match('#\[quote=(.+?)\](.+?)\[/quote\]#siU', $string) == 1 )
{
$string = preg_replace('#\[quote=(.+?)\](.+?)\[/quote\]#siU', '<br><strong>QUOTE:\\1</strong><div class="quote">\\2</div>', $string);
}
?>

Echter dit werkt niet naar behoren en de output is iets als:

<strong>QUOTE:persoon1]lorem ipsum[quote=persoon2</strong><div class="quote">ipsumlorem[ /quote ]</div>


Wie heeft de oplossing?

Reageren