Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

50 users online



If you'd like to have BBcode on your shoutbox.

If you'd like to have BBcode on your shoutbox.

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 3
CDude

CDude

nothing
Status: Offline!

If you'd like to have BBcode on your shoutbox.

been fondling around with regex and here's what i came up with. feel free to copy it. It's quite easy to add more tags.

$str = 'How cool this is bold but this is not Sad. However this is Italic..yay!!';
$bold = '/(\[B\])(.+)(\[\/B\])/';
$italic = '/(\[I\])(.+)(\[\/I\])/';

$str = preg_replace($bold,'<b>\\2</b>',$str);
$str = preg_replace($italic,'<i>\\2</i>',$str);
print $str;

if you want to add more, simply copy $bold or $italic and rename it. let's say i want to center certain text. I copy $bold and replace B with CENTER

$center = '/(\[CENTER\])(.+)(\[\/CENTER\])/';

then you copy one of the replace string, see the <b>\\2</b> ??? just change the tag to center, so for centering, you'll have <center>\\2</center>

now you have

$str = preg_replace($cemter,'<center>\\2</center>',$str);

cool eh? just keep doing it for every tags you want. I've worked on one for [IMG] [URL] tags but it's not easy to modify. The only tags i could think of is. <p> <center> <i> <b> <marquee> <blink> <small> <large>. So on...

___________________

http://celerondude.com

darkobjects

darkobjects

Status: Offline!

wouldnt it be <b>\\1</b> ?

___________________


What was I talking about?

http://hosted.oxyscripts.com/sigs/sigs.php?id=13
-proud user of FIREBIRD

CDude

CDude

nothing
Status: Offline!

it's 2.

http://www.php.net/manual/en/function.preg-replace.php

0 is the whole thing
1 is the opening tage, [ B ]
2 is the text in between the tags
3 is the closing tag [/ B ]

___________________

http://celerondude.com

Last edited by CDude, July 29th, 2002 02:20 AM (Edited 1 times)

ikellen

ikellen

dude
Status: Offline!

cool.............but I worry about people hacking using that, like you said in the "For those of you with shoutboxes" post.

___________________

http://www.kellenholt.com/images/eg_sig.gif
:: KellenHolt.com
:: KellenHolt.com Forums - No Frills Discussion
:: Need Small Hosting Plan? CLICK

CDude

CDude

nothing
Status: Offline!
Quote:

Originally posted by ikellen
cool.............but I worry about people hacking using that, like you said in the "For those of you with shoutboxes" post.

they can't hack it. there is no holes in this one. Even this forum uses it and it's been fine.

___________________

http://celerondude.com

CyberKill3r

CyberKill3r

Status: Offline!

Hey CDude nice stuff
++ckill3r

___________________

Grand Premier of CyberKill3r Episode I website on some time in the future. With a lot of tutorials and scripts free to download, and much more...
..::CyberKill3r.

Oxy

Oxy

Neverside Newbie
Status: Offline!

Yep nice code CDUDE Smile I'm sure this will help some people.

___________________

RAAAH

kobs

kobs

Lost in Hollywood
Status: Offline!

cool man:D

___________________

"The man who makes no mistakes does not usually make anything." - Edward J. Phelps

Adam

Adam

Status: Offline!

now...we want a 10 thousand page essay on how to write a forum like vBulletin PHP :madface

___________________


Current Project: LivermoreMuscle.com
Sig Hosted by Motorspin

cypher

cypher

Status: Offline!

Yer! Tongue

___________________

cypher

Page 1 out of 3
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0184 seconds.