A new version of the UBB conversion program

Source: Internet
Author: User
Tags regular expression
Ubb| program Remember to post a UBB code converted to HTML format code, a few days ago read UBB source code. So there's this new version. Note that this version may not be used properly, see note in detail.
This code translates the user-entered UBB code into HTML format, noting that it requires the support of script Engine 5.0 (enabling
With the RegExp object)

Note: used in pattern () will know the value of the RegExp memory search, which is the first (), the rest of the analogy. But the $
The syntax is not supported by the 5.0 version of Vbscript.dll, I checked the version on my machine (IE 5.5 was installed),
The Vbscript.dll version was found to be 5.50.4629, and the last modification date is December 25. This version supports the words
method, this simple improvement makes the function of RegExp gradually close to Perl's regular expression

function Ubbcode (strcontent)


Dim objregexp
Set objregexp=new REGEXP
Objregexp.ignorecase =true
Objregexp.global=true
' URL
Objregexp.pattern= "(\[url\]) (http:\/\/\s+?) (\[\/url\]) "
Strcontent= Objregexp.replace (strcontent, "<a href=" "$" "
Target=_blank>$2</a> ")
Objregexp.pattern= "(\[url\]) (\s+?) (\[\/url\]) "
Strcontent= Objregexp.replace (strcontent, "<a href=" "Http://$2" "
Target=_blank>$2</a> ")
' Email
Objregexp.pattern= "(\[email\]) (\s+\@\s+?) (\[\/email\]) "
Strcontent= Objregexp.replace (strcontent, "<a
href= "" Mailto:$2 "" >$2</A> ")

Objregexp.pattern= "(\[img\]) (\s+?) (\[\/img\]) "
Strcontent=objregexp.replace (strcontent, "
Objregexp.pattern= "(\[quote\]) (. +?) (\[\/quote\]) "
Strcontent=objregexp.replace (strcontent, "<blockquote><font size=1
Face= "" Verdana, Arial "" >quote:</font><HR>$2<HR></BLOCKQUOTE> "

Objregexp.pattern= "(\[i\]) (. +?) (\[\/i\]) "
Strcontent=objregexp.replace (strcontent, "<i>$2</i>")

Objregexp.pattern= "(\[b\]) (. +?) (\[\/b\]) "
Strcontent=objregexp.replace (strcontent, "<b>$2</b>")
Set objregexp=nothing
Ubbcode=strcontent
End Function
The original conversion process, excerpted from the freeware version of the UBB forum, can be
http://www.ultimatebb.com/Download (Perl CGI method)
Sub Ubbcode {

my $ThePost = shift;
$ThePost =~ s/(\[url\]) (http:\/\/\s+?) (\[\/url\])/<a href= "$"
Target=_blank>$2<\/a>/ISG;

$ThePost =~ s/(\[url\]) (\s+?) (\[\/url\])/<a href= "http:\/\/$2"
Target=_blank>$2<\/a>/ISG;

$ThePost =~ s/(\[email\]) (\s+\@\s+?) (\[\/email\])/<a
href= "mailto:$2" >$2<\/A>/isg;

if (($UBBImages eq "on") && ($OverrideImages ne "yes")) {
$ThePost =~ s/(\[img\]) (\s+?) (\[\/img\])//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);

}
Learn about the comrade of ASP, do not give up the study of CGI, especially some foreigner's CGI program, look after to our ASP programming
It's going to be a big inspiration.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.