Zoklet.net

Go Back   Zoklet.net > Technology > Technophiles and Technophiliacs > Codes of all kinds

Reply
 
Thread Tools
  #1  
Old 01-22-2010, 12:17 AM
TwinkleTits TwinkleTits is offline
Member
 
Join Date: Jan 2009
Thanks: 116
Thanked 17 Times in 16 Posts
Default Need help with this BBCode parser

Heres the parser I'm using
http://www.zoklet.net/bbs/showthread.php?t=52363
its worked well for everything up until now. I put in some table BBCodes
Code:
"'\[TABLE\](.*?)\[/TABLE\]'" => "<table class=\"bb_table\">\\1</table>",

"'\[HEADING\](.*?)\[/HEADING\]'" => "<th>\\1</th>",
"'\[HEADING span=(.*?)\](.*?)\[/HEADING\]'is" => "<th colspan=\\1>\\2</th>",

"'\[ROW\](.*?)\[/ROW\]'" => "<tr>\\1</tr>",
"'\[ROW span=(.*?)\](.*?)\[/ROW\]'is" => "<tr colspan=\\1>\\2</tr>",

"'\[COL\](.*?)\[/COL\]'" => "<td>\\1</td>",
"'\[COL span=(.*?)\](.*?)\[/COL\]'is" => "<td rowspan=\\1>\\2</td>",
the problem is I can't put in line breaks like
 
[ROW]
[COL]
data
[/COL]
[/ROW]
it will only parse it if its in a continuous line like
[ROW][COL]data[/COL][/ROW]it will get way too confusing putting in tables with a lot of data if you can't use line breaks. How would I get that parser to accept line breaks?
Reply With Quote
  #2  
Old 01-25-2010, 06:22 AM
Axiom Axiom is offline
Duke
 
Join Date: May 2008
Thanks: 21
Thanked 53 Times in 42 Posts
Default Re: Need help with this BBCode parser

Add the i & s modifiers to all your regex's. Right now you only have them on lines containing the span attribute.

Does that make sense?

View the text on this page titled: s (PCRE_DOTALL)
http://php.net/manual/en/reference.p....modifiers.php
Reply With Quote
The following users say "It is so good to hear it!":
TwinkleTits (01-25-2010)
  #3  
Old 01-25-2010, 06:24 AM
Axiom Axiom is offline
Duke
 
Join Date: May 2008
Thanks: 21
Thanked 53 Times in 42 Posts
Default Re: Need help with this BBCode parser

FYI: I almost always use /msi as the modifier on my PHP regex's. It saves a lot of time for me...
Reply With Quote
  #4  
Old 01-25-2010, 04:20 PM
TwinkleTits TwinkleTits is offline
Member
 
Join Date: Jan 2009
Thanks: 116
Thanked 17 Times in 16 Posts
Default Re: Need help with this BBCode parser

Quote:
Originally Posted by Axiom View Post
Add the i & s modifiers to all your regex's. Right now you only have them on lines containing the span attribute.

Does that make sense?

View the text on this page titled: s (PCRE_DOTALL)
http://php.net/manual/en/reference.p....modifiers.php
Sorry I shoulda replied earlier I looked over the code and figured it out. Yeah you're right I needed to add that "is" so the code became
Code:
"'\[TABLE\](.*?)\[/TABLE\]'is" =>
Thanks anyway.
Reply With Quote
Reply

Bookmarks

Tags
bbcode, parser

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling PHP functions using BBCode TwinkleTits Codes of all kinds 6 01-30-2010 02:58 AM
Archived: Simple BBCode Parser (PHP) TwinkleTits Codes of all kinds 2 08-12-2009 06:55 PM
DIY PHP BBCode TwinkleTits Codes of all kinds 2 06-24-2009 11:04 PM


All times are GMT. The time now is 04:08 PM.


Hot Topics
On IRC
Users: 4
Messages/minute: 0
Topic: "http://www.zoklet.net/..."
Users: 20
Messages/minute: 0
Topic: "ask ibm why atlantis is real"
Users: 10
Messages/minute: 0
Topic: "So wie ich die sache sehe ist die intelligenz bereits ausgerot..."
Advertisements
Your ad could go right HERE! Contact us!

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.