Computer Help and Spyware Removal Computer Help and Spyware Removal Computer Help and Spyware Removal Computer Help Forums Windows Startup Programs Database Spyware and Malware Removal Guides Computer Tutorials Uninstall Database File Database Computer Glossary Computer Resources
 

Welcome Guest ( Log In | Click here to Register a free account now! )



Register a free account to unlock additional features at BleepingComputer.com
Welcome to Bleeping Computer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.
Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


Important Announcement: The winners of the BC Million Post contest have been announced. You can read who the winners are at this post.

- BleepingComputer Management
 
Reply to this topicStart new topic
> Converting Html To Bbcode
cambot001
post Dec 23 2005, 05:36 AM
Post #1


New Member
*

Group: Members
Posts: 7
Joined: 28-August 05
Member No.: 32,518



I'm looking for an application or script to convert basic html tags to bbcode. Nothing fancy, just the commonly used tags for images, hyperlink, bold, etc. so I don't have to do it manually.

Google came up with a number of methods to convert bbcode to html, but not the other way around.

Unfortunately I'm not that well-versed with regular expressions. Maybe someone could give pointers?

Some options I have are:

PHP - This article, Simple and Complex BBcode with PHP, uses str_replace to convert bbcode to html:

CODE
$string = 'This is [b]cool[/b] - [url=http://www.tutorio.com]Tutorio.com Tutorials[/url]
$bb-replace = array ('/(\[[Bb]\])(.+)(\[\/[Bb]\])/','/(\[url=)(.+)(\])(.+)(\[\/url\])/');
$bb-replacements = array ('<b>\\2</b>','<a href="\\2">\\4</a>');
$string = preg_replace($bb-replace, $bb-replacements, $string);
print $string;
Textpad - Maybe a macro could handle this.
Go to the top of the page
 
+Quote Post
Eveccker
post Jan 4 2006, 02:39 PM
Post #2


New Member
*

Group: Members
Posts: 2
Joined: 4-January 06
Member No.: 48,616



I have a simple bbcode parser for my website, you can look at it and learn a bit:
CODE
$string = "[b]bold['b'] [i]italic[/i] [u]underline[/u]";
$bb=array(
"[b]" => "<b>",
"[/b]" => "</b>",
"[i]" => "<i>",
"[/i]" => "</i>",
"[u]" => "<u>",
"[/u]" => "</u>",
);
$string = str_replace(array_keys($bb), array_values($bb), $s);
echo $string;
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 22nd November 2008 - 08:40 AM


Advertise   |   About Us   |   Terms of Use   |   Privacy Policy   |   Contact Us   |   Site Map   |   Chat   |   Tutorials   |   Uninstall List
Discussion Forums   |   The Computer Glossary   |   Resources   |   RSS Feeds   |   Startups   |   The File Database   |   Malware Removal Guides

© 2003-2008 All Rights Reserved Bleeping Computer LLC.