A new version of ubb Conversion Program

Source: Internet
Author: User

Remember to paste a ubb code into html format, read the source code of ubb a few days ago. So with this new version. Note that this version may not work properly yet. For details, see note.
This code converts user-entered ubb code into html format. Note that Script Engine 5.0 is required (
RegExp object used)
Note: Using () in pattern will know the value found in regexp memory, $1 is the first (), and the rest is similar. But for $2
The syntax is not supported by vbscript. dll of version 5.0. I checked the version on my machine (I installed ie 5.5 ),
It is found that the vbscript. dll version is 5.50.4629, And the last modification date is July 29, December 25. This version supports $1 and other languages.
This simple improvement gradually makes regexp's function closer 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 =" "$2" "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 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

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.