RegEx problems ([quote] tags)
Posted: Tue Sep 28, 2004 11:12 am
Ok so both my quote tags work, I used str replace before but users could use [ end quote] (end == /) and break the tables.
So Im using preg replace, however when a quote tag of the same kind is within another it works, but if a is in b then it doesn work (vica versa).
a = [ quote ]
b = [ quote = var ]
Regex
You can see tests (specifically the top one - which shows the problem) here ; http://forumz.wuggawoo.co.uk/index/test
So Im using preg replace, however when a quote tag of the same kind is within another it works, but if a is in b then it doesn work (vica versa).
a = [ quote ]
b = [ quote = var ]
Regex
Code: Select all
$forumz_post = preg_replace('/(?<!\\\\)\[quote(?::\w+)?\](.*?)\[\/quote(?::\w+)?\]/si',
"<table cellspacing="1" cellpadding="4" class="table">
<tr><td class="headbars">Quote</td></tr>
<tr><td class="cell">\\1</td></tr></table>\n", $forumz_post);
$forumz_post = preg_replace('/(?<!\\\\)\[quote(?::\w+)?=(?:"|"|'')?(.*?)["'']?(?:"|"|'')?\](.*?)\[\/quote\]/si',
"<table cellspacing="1" cellpadding="4" class="table">
<tr><td class="headbars">Quote (\\1)</td></tr>
<tr><td class="cell">\\2</td></tr></table>\n", $forumz_post);You can see tests (specifically the top one - which shows the problem) here ; http://forumz.wuggawoo.co.uk/index/test