I remember pasted a code that converts ubb code to html format before, and read the source code of ubb a few days ago. So with this new version. Note that this version may not be used normally yet, please see the note for details.
This code converts the ubb code entered by the user into html format. Note that the support of Script Engine 5.0 is required (to enable
Use RegExp object)
Note: Using() in pattern will know the value searched for by regexp memory, $1 is the first(), and so on. But $2
The syntax is not supported by version 5.0. I checked the version on my machine (I have installed ie 5.5).
The discovered version is 5.50.4629 and the last modified date is December 25. This version supports words like $1
Method, this simple improvement makes the function of regexp gradually closer to the regular expression of perl
function UBBCode(strContent)
dim objRegExp
Set objRegExp=new RegExp
=true
=True
'url
="(\[URL\])(http:\/\/\S+?)(\[\/URL\])"
strContent= (strContent,"<A HREF=""$2"" TARGET=_blank>$2</A>")
="(\[URL\])(\S+?)(\[\/URL\])"
strContent= (strContent,"<A HREF=""http://$2"" TARGET=_blank>$2</A>")
'email
="(\)(\S+\@\S+?)(\[\/EMAIL\])"
strContent= (strContent,"<A HREF=""mailto:$2"">$2</A>")
="(\[IMG\])(\S+?)(\[\/IMG\])"
strContent=(strContent,"<IMG SRC=""$2"">")
="(\[QUOTE\])(.+?)(\[\/QUOTE\])"
strContent=(strContent,"<BLOCKQUOTE><font size=1
face=""Verdana, Arial"">quote:</font><HR>$2<HR></BLOCKQUOTE>")
="(\[i\])(.+?)(\[\/i\])"
strContent=(strContent,"<i>$2</i>")
="(\[b\])(.+?)(\[\/b\])"
strContent=(strContent,"<b>$2</b>")
set objRegExp=Nothing
UBBCode=strContent
end function
The original conversion program, excerpted from the freeware version of the ubb forum, can be downloaded from / (Perl CGI method)
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);
}
Comrades who study Asp, don’t give up learning about CGI, especially some foreign CGI programs. After reading it, it will be of great inspiration to our asp programming.