<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: bbcode code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 11 Oct 2008 22:01:10 GMT</pubDate>
    <description>DZone Snippets: bbcode code</description>
    <item>
      <title>BBCode</title>
      <link>http://snippets.dzone.com/posts/show/2740</link>
      <description>Format BBCode input&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function bbcode_format($var) {&lt;br /&gt;	$search = array(&lt;br /&gt;		'/\[b\](.*?)\[\/b\]/is',                                &lt;br /&gt;		'/\[i\](.*?)\[\/i\]/is',                                &lt;br /&gt;		'/\[u\](.*?)\[\/u\]/is',&lt;br /&gt;		'/\[img\](.*?)\[\/img\]/is',&lt;br /&gt;		'/\[url\](.*?)\[\/url\]/is',&lt;br /&gt;		'/\[url\=(.*?)\](.*?)\[\/url\]/is'&lt;br /&gt;		);&lt;br /&gt;&lt;br /&gt;	$replace = array(&lt;br /&gt;		'&lt;strong&gt;$1&lt;/strong&gt;',&lt;br /&gt;		'&lt;em&gt;$1&lt;/em&gt;',&lt;br /&gt;		'&lt;u&gt;$1&lt;/u&gt;',&lt;br /&gt;		'&lt;img src="$1" /&gt;',&lt;br /&gt;		'&lt;a href="$1"&gt;$1&lt;/a&gt;',&lt;br /&gt;		'&lt;a href="$1"&gt;$2&lt;/a&gt;'&lt;br /&gt;		);&lt;br /&gt;&lt;br /&gt;	$var = preg_replace ($search, $replace, $var);&lt;br /&gt;&lt;br /&gt;	return $var;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 30 Sep 2006 07:09:42 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2740</guid>
      <author>Shpigford (Josh)</author>
    </item>
    <item>
      <title>a basic regex example in ruby</title>
      <link>http://snippets.dzone.com/posts/show/2239</link>
      <description>This is a simple regex in ruby. It returns an array of all bbcode urls.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;bbcode_urls = text.scan(/\[url={0,1}.*?\].*?\[\/url\]/)&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 30 Jun 2006 23:24:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2239</guid>
      <author>bloc ()</author>
    </item>
    <item>
      <title>ubbcode</title>
      <link>http://snippets.dzone.com/posts/show/109</link>
      <description>a function to convert common used bbcode tags to html... as usually used in message boards and some blog software.&lt;br /&gt;&lt;br /&gt;it handles img, email, link, b, u and i tags...&lt;br /&gt;&lt;br /&gt;for example&lt;br /&gt;&lt;code&gt;&lt;br /&gt;[b]test[/b]&lt;br /&gt;[url=http://blah.com]blah[/url]&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;will become:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://blah.com" target="_blank"&gt;blah&lt;/a&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function ubbcode($posting) {&lt;br /&gt;	$posting=eregi_replace("\[img\]([^\[]+)\[/img\]","&lt;img src=\"\\1\" border=\"0\"&gt;",$posting);&lt;br /&gt;	$posting=eregi_replace("\[email\]([^\[]+)\[/email\]","&lt;a href=\"mailto:\\1\"&gt;\\1&lt;/a&gt;",$posting);&lt;br /&gt;	$posting=eregi_replace("\[email=([^\[]+)\]([^\[]+)\[/email\]","&lt;a href=\"mailto:\\1\"&gt;\\2&lt;/a&gt;",$posting);&lt;br /&gt;	$posting=eregi_replace("\[url=([^\[]+)\]([^\[]+)\[/url\]","&lt;a href=\"\\1\" target=\"_blank\"&gt;\\2&lt;/a&gt;",$posting);&lt;br /&gt;	$posting=eregi_replace("\[url\]([^\[]+)\[/url\]","&lt;a href=\"\\1\" target=\"_blank\"&gt;\\1&lt;/a&gt;",$posting);&lt;br /&gt;    $posting=eregi_replace("\[b\]","&lt;strong&gt;",$posting);&lt;br /&gt;    $posting=eregi_replace("\[/b\]","&lt;/strong&gt;",$posting);&lt;br /&gt;    $posting=eregi_replace("\[u\]","&lt;u&gt;",$posting);&lt;br /&gt;    $posting=eregi_replace("\[/u\]","&lt;/u&gt;",$posting);&lt;br /&gt;    $posting=eregi_replace("\[i\]","&lt;em&gt;",$posting);&lt;br /&gt;    $posting=eregi_replace("\[/i\]","&lt;/em&gt;",$posting);&lt;br /&gt;&lt;br /&gt;    return $posting;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 10 Apr 2005 02:21:38 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/109</guid>
      <author>ichigo ()</author>
    </item>
  </channel>
</rss>
