Implementation of UBB code (ASP)

Source: Internet
Author: User
Tags chr html tags regular expression
This part of the code is obtained from other materials on the Internet, and I modified and improved it. I used the clumsy method replace (hey, I have not mastered the regular expression) to implement the UBB code, I have always felt that this method is not stupid, so I am sorry to post it. Some netizens have used it today and want to make it valuable to beginners. So I will publish all the source code for reference. Because of the time relationship, without any annotations, I will gradually improve it.
The ubb code implementation function of this section
[B] [/B] bold, replaced with html tag <B> </B>
[I] [/I] italic, replaced with html markup <I> </I>
[U] [/U] is underlined and replaced with html markup <u> </u>
[Br] line feed, with html tags <br>
[COLOR] [/COLOR] text color. Replace it with the html tag <font COLOR = xxx> </font>.
Usage: [COLOR = xxx] Text [/COLOR].
[MYCODE] [/MYCODE] retains the source code input format and replaces it with the html tag <pre> </pre>. The text will be completely retained and will not be replaced by UBB.
[URL] [/URL] Hyper-connection, with the html tag <a> </a>.
Usage: [URL = connection address] text displayed [/URL] (long format) or [URL] connection address [/URL] (short format ), do not quote the two ends of "connection.
[EMAIL] [/EMAIL] email address. Replace it with the html tag <a href = mailto: xxx> </a>.
Usage: [EMAIL = EMAIL address] name [/EMAIL] (long format) or [EMAIL] EMAIL address [/EMAIL] (short format ). The "address" must be in valid email format.
[IMAGE] [/IMAGE] IMAGE, with the html tag .
Usage: [IMAGE] IMAGE address [/IMAGE]. The "address" must be the complete path of the image.
[SOUND] [/SOUND] Multimedia sound. You can put the url of the song behind the SOUND.
Usage: [SOUND = Song address] song name [/SOUND].
[FLASH] [/FLASH] FLASH. You can put the FLASH url after flash.
Usage: [FLASH = flash address] FLASH name [/FLASH].
The code is as follows:
You only need to call icode2html () to implement the UBB text.
Yourtext = "..." 'your text contains the UBB mark
The following two parameters of icode2html (yourtext,) 'indicate whether to disable image, sound, and flash.
<%
Function icode2Html (str, unimage, unsound)
If not str <> "then exit function ', if it is an empty string
Str = HTMLEncode (str) 'encode the text in HTML first
Str = replace (str, chr (13) + chr (10), "<br>") 'replace the text carriage return linefeed with the line feed of HTML
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.