Jump to content

[HARD] Multi quote regex (BBCode)


eevan79

Recommended Posts

This is too hard for me and I need some expert opinion if possible.

 

I want to implement multiquote feature with [ quote] [ /quote ] BB tags. I have 2 regex for BBCodes: [ quote = username] and just [ quote]

 

Here is BBCode tags:

    '/\[ quote\][\r\n]*(.+?)\[\/quote \][\r\n]*/si',
    '/\[ quote (.+?)\][\r\n]*(.+?)\[\/quote\][\r\n]*/si',

and replace:

 

 '<div class="quote">\\1</div>',
'<div class="quote"><div class="quoting">\\1: </div>\\2</div>',

 

When user click on Quote button (on posts page) I use this preg_replace:

$text = preg_replace(
                          '/<div class=\" quote \">(.+?): <\/div>(.+?)<\/div>/is', 
                          '[ quote ]\\2[/ quote ]', 
                          $text);

Note: this codes are without spaces (I must use space to show correct code)

 

To show quoted text in post form I use this:

$quoted_text = '[ quote=' . mysql_real_escape_string($_GET['u']) . ']' . $text['post_content'] . '[ /quote]';

(this is in textarea : <textarea>$quoted_text </textarea>)

 

Here is screenshot how it looks like.

First two quotes:

quotew.gif

 

 

and third quote have "bugs"

3rdquote.gif

 

Any ideas how to fix multiple quotes?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.