Help! BBCode Parsing?

Discussion in 'PHP' started by irunbackwards, Oct 28, 2006.

  1. #1
    I'm having trouble..

    I'm trying to parse bbcode phpbb gives me from post entries , but it is giving me odd bbcodes like this:

     [b:53cb5]I. Master Fisherman[/b:53cb5]
    
    [b:53cb5][url=http://www.digg.com/gaming_news/World_of_Warcraft_Burning_Crusade_Outlanders_Guide_to_Master_Fishing:53cb5]digg it![/url:53cb5][/b:53cb5]
    Code (markup):
    it is giving me a colon and a random alphanumeric string as the $uid for it... how can i just ignore this and parse the bbcode like that normally.

    you can see it @ www.gnomeproblem.com
     
    irunbackwards, Oct 28, 2006 IP
  2. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    streety, Oct 28, 2006 IP
  3. irunbackwards

    irunbackwards Peon

    Messages:
    791
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm still having trouble because the odd :uid thing that phpbb gives me.. because of this i can't use the class yet

    how can i get rid of the stupid uid?
     
    irunbackwards, Oct 28, 2006 IP
  4. irunbackwards

    irunbackwards Peon

    Messages:
    791
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    anyone? :/
     
    irunbackwards, Oct 29, 2006 IP
  5. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Your best bet would be solving why the phpbb code isn't working correctly.

    Failing that you should be able to remove the garbage using a regular expression

    
    $cleaned_bbcode_string = preg_replace("/\[b:[0-9a-z]{5}\]/", "[b]", $weird_bbcode_string);
    
    PHP:
    You would need something similar for the closing tag and all the other tags.
     
    streety, Oct 29, 2006 IP
  6. irunbackwards

    irunbackwards Peon

    Messages:
    791
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks, now my question is this:

    how can i comebine these two functions into one:

    $post_info[] = preg_replace("/\[b:[0-9a-z]{5}\]/", "[b]", $row);
    Code (markup):
    $post_info[] = preg_replace("/\[\/b:[0-9a-z]{5}\]/", "[/b]", $row);
    Code (markup):
    edit: uhm they're not displaying correctly i think vb's
     function is bugged...
    
    check out what i have here:
    
    http://www.madebyai.com/clipboard/get/4285d05b6a11f49f14fa8ffb46ce3e692b7f08c9454554e2.txt
    Code (markup):
     
    irunbackwards, Oct 29, 2006 IP
  7. irunbackwards

    irunbackwards Peon

    Messages:
    791
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i fixed that.. now another question.

    how can i modify that code to work with a [ url ] bbcode?

    [url=http://img186.imageshack.us/my.php?image=teleportercp8.gif:ea8a0][img]http://img186.imageshack.us/img186/2955/teleportercp8.th.gif[/img][/url:ea8a0]
    Code (markup):
     
    irunbackwards, Oct 29, 2006 IP
  8. irunbackwards

    irunbackwards Peon

    Messages:
    791
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Everthing's been solved, thanks alot.
     
    irunbackwards, Oct 29, 2006 IP
  9. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks great, glad you got it all working.
     
    streety, Oct 29, 2006 IP