QUOTE(BetaWar @ 31 Aug, 2008 - 01:13 PM)

Have you tried using
(.?*) that shopuld take any and all characters until it matches up with the closing
CODE
[/ code]
tag.
Well, yes, but it still is just outputting
CODE
[ code ]<br />
class Man<br />
def initialize<br />
end<br />
def jump<br />
puts "The Man Jumps!"<br />
end<br />
end<br />
[/ code ]<br />
I'll paste the entire functions file below, maybe something else is happening that stopping this from working...
CODE
<?php
function BBCode($input)
{
// convert [image]image_link[/image]
$pattern[] = '/\[image\](.*?)\[\/image\]/i';
$replace[] = '<img src="$1" border="0" alt="$1"></img>';
// convert [url=URL]link_title[/url]
$pattern[] = '/\[url=(.*?)\](.*?)\[\/url\]/i';
$replace[] = '<a href="$1" target="_blank">$2</a>';
// convert [hover=URL]Text[/hover]
$pattern[] = '/\[hover=(.*?)\](.*?)\[\/hover\]/i';
$replace[] = '<a onmouseover="Tip(\'$1\', WIDTH, \'40\', BGCOLOR, \'#efe0c0\', BORDERCOLOR, \'#e3c992\')" onmouseout="UnTip()">$2</a>';
// convert [video=URL]link_title[/video]
$pattern[] = '/\[video=(.*?)\](.*?)x(.*?)\[\/video\]/i';
$replace[] = '<embed
src="http://madtast.com/pages/video/player.swf"
width="$3" height="$2" allowscriptaccess="always"
allowfullscreen="true"
flashvars="height=$2&width=$3&file=$1&backcolor=0xe3c992$4&stretching=uniform"
/>';
// convert [url]url_link[/url]
$pattern[] = '/\[url\]([.\n]*)\[\/url\]/i';
$replace[] = '<a href="$1">$1</a>';
// convert [ code ]code[/ code ]
$pattern[] = '/\[ code \](.?*)\[\/ code \]/i';
$replace[] = codize('$1');
// convert [file=file_name]file_link[/file]
$pattern[] = '/\[file=(.*?)\](.*?)\[\/file\]/i';
$replace[] = '<P title="Download" STYLE="margin-bottom: 0in; margin-left: 10px; margin-right: 10px; text-indent: 24px; background: url(/css/images/emblems/file.gif) no-repeat top left;"><a href="/download.php?download_file=$1">$2</a></P>';
// convert [new]new_text[/new]
//$pattern[] = '/\[new\](.*?)\[\/new\]/i';
//$replace[] = '<P title="New" STYLE="margin-bottom: 0in; text-indent: 24px; background: url(/css/images/emblems/new.gif) no-repeat top left;">$1</P>';
// convert [idea]idea[/idea]
//$pattern[] = '/\[idea\](.*?)\[\/idea\]/i';
//$replace[] = '<P title="Idea" STYLE="margin-bottom: 0in; text-indent: 22px; background: #f3e7d0 url(/css/images/emblems/idea.gif) no-repeat top left;">$1</P>';
// convert [important]!!![/important]
//$pattern[] = '/\[important\](.*?)\[\/important\]/i';
//$replace[] = '<P title="Important" STYLE="margin-bottom: 0in; text-indent: 24px; background: #ecb1b1 url(/css/images/emblems/important.png) no-repeat top left;">$1</P>';
// convert [b]text[/b]
$pattern[] = '/\[b\](.*?)\[\/b\]/i';
$replace[] = '<b>$1</b>';
// convert [title]text[/title]
$pattern[] = '/\[title\](.*?)\[\/title\]/i';
$replace[] = '<a name="$1"></a> <b>$1</b>';
//Making Quotes Possible ["]quote["]
//$pattern[] = '/\["](.*?)\["]/i';
//$replace[] = '<font color="gray">"$1"</font>';
// convert [i]text[/i]
$pattern[] = '/\[i\](.*?)\[\/i\]/i';
$replace[] = '<i>$1</i>';
return preg_replace($pattern, $replace, $input);
}
function article_script($input, $article_id, $title)
{
$date = date("m/d/Y");
$username = $_SESSION['username'];
if(session_is_registered(myusername))
{
$f_username = $username;
}
else
{
$f_username = "Guest";
}
//Allows Use Of HTML <center>
$pattern[] = '<center>';
$replace[] = '<center>';
//Allows Use Of HTML </center>
$pattern[] = '</center>';
$replace[] = '</center>';
//Allows Use Of HTML <br>
$pattern[] = '<br>';
$replace[] = '<br>';
//Allows Use Of BBCode [br]
$pattern[] = '[br]';
$replace[] = '<br>';
//Formal
//$pattern[] = '%formal%';
//$replace[] = '<P STYLE="margin-bottom: 0in; text-indent: 22px;">';
//Quote
//$pattern[] = '%quote%';
//$replace[] = '<P STYLE="margin-bottom: 0in; text-indent: 22px; background: url(/css/images/emblems/quote.gif) no-repeat top left;">';
//Normal
//$pattern[] = '%normal%';
//$replace[] = '<P STYLE="margin-bottom: 0in; text-indent: 22px;">';
//Simple
//$pattern[] = '%simple%';
//$replace[] = '<P STYLE="margin-bottom: 0in;">';
//End
//$pattern[] = '%end%';
//$replace[] = '</P>';
//Function Replaces
//Article ID
$pattern[] = '%article_id%';
$replace[] = $article_id;
//User
$pattern[] = '%user%';
$replace[] = $f_username;
//Date
$pattern[] = '%date%';
$replace[] = $date;
//Add Tabing Support
$pattern[] = ' ';
$replace[] = ' ';
//Add Indenting
$pattern[] = '[indent]';
$replace[] = ' ';
$input = nl2br($input);
$input = BBCode($input);
//Replace RUN!
$input = str_replace($pattern, $replace, $input);
//Resets
$f_username = "";
//Add Some Styling
$input = '
<SPAN>
<P style="padding-left: 10px; padding-right: 10px;" title="'.$title.'">
'.$input.'
</P>
</SPAN>';
//Return
return $input;
}
function codize($input)
{
$input = repBetween($input);
$pattern[] = 'for';
$replace[] = '<font class="keyword"><b>for</b></font>';
$pattern[] = 'while';
$replace[] = '<font class="keyword"><b>while</b></font>';
//Note the space after loop.
$pattern[] = 'loop ';
$replace[] = '<font class="keyword"><b>loop</b> </font>';
$pattern[] = 'printf';
$replace[] = '<font class="keyword"><b>printf</b></font>';
$pattern[] = 'print';
$replace[] = '<font class="keyword"><b>print</b></font>';
$pattern[] = 'return';
$replace[] = '<font class="keyword"><b>return</b></font>';
//Note the space after def.
$pattern[] = 'def ';
$replace[] = '<font class="keyword"><b>def</b> </font>';
$pattern[] = 'if';
$replace[] = '<font class="keyword"><b>if</b></font>';
$pattern[] = 'elif';
$replace[] = '<font class="keyword"><b>elif</b></font>';
$pattern[] = 'else';
$replace[] = '<font class="keyword"><b>else</b></font>';
$pattern[] = ' ';
$replace[] = ' ';
$pattern[] = '<br />';
$replace[] = '</li><li bgcolor="">';
$input = nl2br($input);
$input = str_replace($pattern, $replace, $input);
//Return
return $input;
}
?>