适合cgi程序的ubb转换函数源码
拔自cgi程序的ubb转换函数代码,虽然现在用cgi的朋友很少,不过值得学习
sub UBBCode {
my $ThePost = shift;
$ThePost =~ s/(\[URL\])(http:\/\/\S+?)(\[\/URL\])/ <A HREF="$2"
TARGET=_blank>$2<\/A> /isg;
$ThePost =~ s/(\[URL\])(\S+?)(\[\/URL\])/ <A HREF="http:\/\/$2"
TARGET=_blank>$2<\/A> /isg;
$ThePost =~ s/(\)(\S+\@\S+?)(\[\/EMAIL\])/ <A
HREF="mailto:$2">$2<\/A> /isg;
if (($UBBImages eq "ON") && ($OverrideImages ne "yes")) {
$ThePost =~ s/(\[IMG\])(\S+?)(\[\/IMG\])/ <IMG SRC="$2"> /isg;
}
$ThePost =~ s/(\[QUOTE\])(.+?)(\[\/QUOTE\])/ <BLOCKQUOTE><font size="1"
face="Verdana, Arial">quote:<\/font><HR>$2<HR><\/BLOCKQUOTE>/isg;
$ThePost =~ s/(\[i\])(.+?)(\[\/i\])/<i>$2<\/i>/isg;
$ThePost =~ s/(\[b\])(.+?)(\[\/b\])/<b>$2<\/b>/isg;
return ($ThePost);
}