Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
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
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.