vForums Support > Programming & Coding :: Programming Discussion :: > bb code parsing.

bb code parsing. - Posted By I Anoop I (anoop) on 24th Feb 08 at 10:53pm
i want to use BB code on my shoutbox, how would i parse it with PHP?

Re: bb code parsing. - Posted By Michael (wrighty) on 24th Feb 08 at 10:54pm
Code your own parser using RegExp.

Make it take the inputted string, and change the UBBC items to HTML items! {Smile}

Re: bb code parsing. - Posted By Jason (frufru) on 24th Feb 08 at 10:55pm
 
i want to use BB code on my shoutbox, how would i parse it with PHP?


Regular Expressions is the best method I know, and it works quite well on my shoutbox. Peter (former PBsupport mod) claims there is a more 1337 method, but he never got back to me on what that was {Tongue Out}

How much do you know about regular expressions?

Re: bb code parsing. - Posted By I Anoop I (anoop) on 24th Feb 08 at 10:56pm
That's not a bad idea!

Would that be easier than preg_replace?

Re: bb code parsing. - Posted By Marc (cr0w) on 24th Feb 08 at 11:10pm
 
That's not a bad idea!

Would that be easier than preg_replace?


preg_replace() is Regular Expressions. {Wink}

Re: bb code parsing. - Posted By I Anoop I (anoop) on 25th Feb 08 at 12:16am
oopsie, thanks.

Re: bb code parsing. - Posted By Ross (admin) on 26th Feb 08 at 12:19am
 
 
i want to use BB code on my shoutbox, how would i parse it with PHP?


Regular Expressions is the best method I know, and it works quite well on my shoutbox. Peter (former PBsupport mod) claims there is a more 1337 method, but he never got back to me on what that was {Tongue Out}

How much do you know about regular expressions?


Well I know one alternative method is to split the string into sections and walk through each section rebuilding the formatted text as you go. That's how I wrote both the table parser and the quote parser here. But that still uses some regular expressions and I don't see how it'd make parsing simplier tags such as bold or italic any better.

Re: bb code parsing. - Posted By Paddy (artemis) on 26th Feb 08 at 2:11am
There are ones premade you can use.

http://www.corz.org has a nice one. ^_^

~Artemis