...

View Full Version : Need help with regex / bbcodes



[vengeance]
10-31-2009, 05:24 PM
Hello.

I'm creating a quote-message function. I want to quote a message, and if another person quotes me, it adds all those extra quotes all-in-one.

Quoting one message works - however, when there's more, the bbcode doesn't work.

Example:



User 1 said:

User 2 said:
Bla bla
True!
Fail!


But when it's displayed, it only turns one pair of
into a plain grey box with text, and the others remain as text "[ quote]" and "[/ quote]".

I hope that made any sense.

My BBcode script is as follows:


<?php
function bbcode($text){
$find = array(
"'\[quote](.*?)\[/quote\]'is"
);

$replace = array(
"<div style=\"border: 1px solid #000000; background: #F2F2F2;\"><div style=\"padding: 3px;\">\\1</div></div>"
);

$text = preg_replace($find,$replace,$text);
return $text;
}
?>


Also to mention, I'm not that great/familiar with regex yet.

Phil Jackson
10-31-2009, 05:42 PM
"'\[quote](.*?)\[/quote\]'is"
<=
"#\[quote\](.*?)\[quote\]#is"

note: This will retrieve the first parent and all children quotes.

[vengeance]
10-31-2009, 06:20 PM
@Phil:

Nothing happened. I also edited your last [ quote] to [ /quote]. But same result as before.

[vengeance]
11-01-2009, 10:45 AM
Can anyone help? :confused: I still haven't figured it out.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum