HaLo2FrEeEk Posted July 30, 2007 Share Posted July 30, 2007 Ok, phpbb, at least, puts a unique ID number into each bbcode tag a user posts, for example, if I were to post bold text and look at the raw code in the database, it would look like this: [b:9f0e836e4c]bold text[/b:9f0e836e4c] Now, it's simple enough to remove those numbers using this regex: [b:[^\]]+] What's really got me stumped, though, is how to do this when the bbcode has attributes, such as size and a quote: Test quote Would end up being: Test quote[/quote:9f0e836e4c] And: Test size turns into: Test size[/size:9f0e836e4c] What I need to know is how I can use one regex to handle both the opening, AND the closing tags for these, and still keeping the attribute value (so saving it to a backreference). EDIT: I got the size one working, I need help with quote though. I used this one for quote, but it only did the opening tag, and not the closing one: preg_replace("[quote:[^\]]+(=[.]*)]", "quote$1", $text); The thought was that if the attribute was there (i.e., an opening tag) then it would save the backreference and replace it, if it's not there, it will ignore it. It doesn't work though, and it only replaces the opening tag, forcing me to have another regex to handle the closing tag. What can I do to fix this? Thank you. EDIT: Regex: ]+(=[.]*)] Turns: Test quote[/quote:9f0e836e4c] Into: [quote="HaLo2FrEeEk"]Test quote[/quote:9f0e836e4c] And regex: ]+(=[.]*)?] Turns: Test quote[/quote:9f0e836e4c] Into: [quote]Test quote[/quote] I'm stumped. Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted July 30, 2007 Author Share Posted July 30, 2007 bump. Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted July 30, 2007 Author Share Posted July 30, 2007 BUMP! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.