Use the "Regular Expression" Object in ASP to implement the UBB-style forum

Source: Internet
Author: User

Last time, we talked about how to use the regular expression object in ASP to verify various data. This article describes the powerful functions of the regular expression object. Next, let's take a look at other functions related to the regular expression object. When surfing the Internet, especially when browsing various forums, we often see the word "UBB Code. What is UBB code? UBB code is a variant of HTML. It is a special TAG used by Ultimate Bulletin Board (a BBS program in foreign countries, which is also used in many places in China. To prevent unintentional or intentional HTML code attacks on the Forum, HTML code is basically blocked in various forums. However, in order to make the forum more colorful ", the Forum will open some custom Tag tags, similar to tags in HTML, such as "[URL], [/URL], [RED], [/RED, it provides functions equivalent to HTML code and prevents malicious attacks on forums. These custom tags are commonly known as UBB code. Currently, trendy forums support UBB code, such as http: // www. Chinaasp. The com (Dynamic Technology Network) Forum supports UBB code. Now, let's use the regular expression object to implement our own rich and colorful UBB code.
First, your Server (IIS or PWS) must have a support environment for VBScript5.0. Generally, IE5.X is installed to support regular expressions.
For common methods and attributes of regular expressions, I have already introduced in detail in my article "using regular expressions to verify data in ASP". For more information, see this article. Here, I will mainly introduce the primary regular expression object method for implementing "UBB code": Replace () method.
The Replace method syntax is as follows:
The Replace method syntax is as follows:
Description
Replace the text found in the regular expression search.
Syntax
Object. Replace (string1, string2)
The syntax of the Replace method includes the following parts:
Partial description
Required. It is always the name of a RegExp object.
Required by string1. String1 is the string to be replaced by text.
Required by string2.
String2 is a replacement text string.
 
Description
The actual mode of the replaced text is set through the Pattern attribute of the RegExp object.
The Replace method returns a copy of string1, where the RegExp. Pattern text has been replaced with string2. If no matching text is found, the original copy of string1 is returned.
Next, we need to determine what UBB code we ultimately want to implement? The UBB code function we want to implement this time is as follows:

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.