Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts

    Need help figuring out this regex expression

    So I'm working on a bb code parser, and I'm on quotes, for which I have this code:

    PHP Code:
    $text preg_replace("/\[quote(?:=\"(\w+?)\")?]/"'<blockquote class="quote"><div class="quotee">\1 says:</div>'$text);
    $text preg_replace("/\[\/quote\]/m"'</blockquote>'$text); 
    It works well. However, later on in the code, I use nl2br, and I'd prefer not to get a br after the block quote (just set a margin below it). I've tried to capture the newlines after the closing blockquote, but with no avail. I've tried:

    Code:
    /\[\/quote\]\s*/m
    /\[\/quote\][\r\n]*/m
    /\[\/quote\][\r\n]{0,2}/m
    Last edited by Keleth; 11-27-2013 at 06:01 PM.

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts
    So I was looking at this further, and I did something very stupid, which resolves this problem. I was running nl2br before I ran the bb parser, which means of course it couldn't find sequential newlines... they were already breaks.

    Ignore me while I go back to the dunce corner.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •