- Joined
- Jun 8, 2007
- Messages
- 1,985
- Reaction score
- 490
I have an issue with this BBcode parser I've been working on. Specifically with the [ quote="name"] tags (minus the first space). I got it working recursively if no name is used, but when one tries to put a name, it only works 1 tier. If they do the first tier with name="name", and all the inner quotes without a name, it works too.
The problem only comes up when I have [ quote="name][ quote="name"][/quote][/quote].
Rather then doing this,
It does this,
I got code and modified it from an example at PHP.net, under preg_replace_callback() function reference. (Their example was for indent, and it did not have two arguments.)
It would be nice to have the quote parser for RageZone..
Anyone do this before? I searched google, but surprisingly, couldn't find something specific to the 'name="name"' recursive problem.. Or at least not one that was solved yet. :
Edit: Silly me, I forgot to include '\=?"?(.*?)"?' in the recursive section, lol.... Now it works great!
The problem only comes up when I have [ quote="name][ quote="name"][/quote][/quote].
Rather then doing this,
It does this,
[ /quote] (minus the space)name said:[ quote="name"] (minus the space)
I got code and modified it from an example at PHP.net, under preg_replace_callback() function reference. (Their example was for indent, and it did not have two arguments.)
PHP:
if(!function_exists(parseQuotesRecursive))
{
function parseQuotesRecursive($input)
{
$regex = '#\[quote\=?"?(.*?)"?\]((?:[^[]|\[(?!/?quote\])|(?R))+)\[/quote\]#i';
if (is_array($input))
{
$input = '<blockquote style="margin: 5px 20px 20px;">'
.'<div style="margin-bottom: 2px;font-size:10px;font-family:sans-serif">'
.'Quote'.( (strlen($input[1])>0) ? ' From <strong>'.$input[1].'</strong>' : '' ).','
.'</div>'
.'<div style="padding:4px;padding-top:0;border:#000 1px inset">'
.$input[2]
.'</div>'
.'</blockquote>';
}
return preg_replace_callback($regex, 'parseQuotesRecursive', $input);
}
}
$text = parseQuotesRecursive($text);
It would be nice to have the quote parser for RageZone..
Anyone do this before? I searched google, but surprisingly, couldn't find something specific to the 'name="name"' recursive problem.. Or at least not one that was solved yet. :
Edit: Silly me, I forgot to include '\=?"?(.*?)"?' in the recursive section, lol.... Now it works great!
PHP:
'#\[quote\=?"?(.*?)"?\]((?:[^[]|\[(?!/?quote\=?"?(.*?)"?\])|(?R))+)\[/quote\]#i'
Last edited: