Using ASP to realize the UBB function of forum

Source: Internet
Author: User
Tags comparison contains expression functions implement numeric numeric value string
Ubb|ubb

A few days ago I read a technical article about how to use regular expression objects in VBScript to implement the UBB functionality in a forum. VBScript provides a very powerful regular expression object, but only 5. More than 5 of the scripting engines can support regular expression objects well, in order to get a version of 5. 5 script engine, you need to install the script engine alone, or install IE5.5, that is, the requirements of the server is more stringent, then there is no other way to implement the UBB function? Of course not, now follow me to use the common VBScript scripting language to achieve powerful UBB functions.

First, in the UBB function, the core function is the most attractive function is to fully support the texture and font properties of the control. Because for security reasons, almost all the forums above the network to screen out the HTML code as much as possible, so as to avoid man-made unintentional damage to the forum, so that although the security of the Forum itself, but users face the content of the posts is always the same color, font, size, Do not expect to see colorful pictures. Ubb code is born from this, specifically how we achieve the above UBB core functions.

Let's start with a detailed description of the syntax of the UBB code we're going to implement:

UBB syntax for supporting textures

Grammar:

Instance:

Description: The result of the above grammar is to display a picture on the page

Second, support the font color UBB syntax:

Syntax: [red] text [/red]

[Green] text [/green]

Wait a minute

instance: [Blue] This is a piece of blue text [/blue]

Description: A section of the above syntax is to display a blue color text

Third, UBB code to support hyper-connection

Syntax: Connection address

Example: http://www.webjx.com

Description: The result of the above syntax is to generate a super connection, which will jump to the connecting address when you click!

Iv. UBB syntax to support email address

Grammar: Your email address [/email]

Example: info@webjx.com

Description: The above code result is to display an email address, when you click with the mouse, will automatically open the software to send e-mail, and the address written on.

V. UBB syntax to support font properties

Syntax: A piece of text, etc.

Instance: A piece of bold text

Description: The result of the above code is to display a bold text

Well, the core function of UBB code is these things, and of course you can add other functions because the syntax of the UBB code is customizable.

Before we begin to implement the UBB function specifically, let's take a look at several important VBScript functions: The InStr function and the Replace function. Perhaps you see here can not help but want to say, this is too simple, oh, in fact, these two functions are indeed we use in programming more frequently two functions, but it also has its own little secret Oh, let's take a look at these two functions of the specific
Grammar:

InStr function

Returns the position of the first occurrence of a string in another string.

INSTR ([Start,]string1, string2[, compare])

Parameters

Start

Options available. A numeric expression that sets the starting position for each search. If omitted, the search begins at the position of the first character. If start contains null, an error occurs. If you have specified compare, you must have the start argument.

String1

Required option. The string expression that accepts the search.

string2

Required option. The string expression to search for.

Compare

Options available. Indicates the numeric value of the comparison type to use when calculating the substring. For numeric values, see the "Settings" section. If omitted, a binary comparison is performed.

Set up

The Compare parameter can have the following values:

Constant

Value

Describe

Vbbinarycompare

0

Performs a binary comparison.

vbTextCompare

1

Performs a text comparison.

return value

The InStr function returns the following values:

If

InStr return

String1 is zero length

0

String1 is null

Null

string2 is zero length

Start

String2 is null

Null

String2 didn't find it.

0

Find string2 in string1.

Find the location of the matching string

Start > Len (string2)

0

It should be noted that the InStr of the function we want to use is its last selectable parameter compare, because our UBB code needs to be case insensitive, and by default the function InStr is to be binary matched, that is to say, case-sensitive, so remember , the value of this compare parameter should be set to 1 to meet our requirements.

Replace function

Returns a string in which a specified number of substrings are replaced with another substring.

Replace (expression, find, replacewith[, compare[, count[, start]])


Parameters

Expression

Required option. A string expression contains a substring to override.

Find

Required option. The substring being searched for.

ReplaceWith

Required option. The substring to replace.

Start

Options available. The location at which to start searching for substrings in expression. If omitted, the default value is 1. When associating with count, you must use the

Count

[1] [2] Next page



Related Article

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.