Recommended: How to output Excel files with ASP One way to use excel in Asp is to link the excel file as a database, and the operation is similar to the access database operation. But this method is not always useful, it should be that excel is not a relational database. For a fixed format,
Asp Regular Expression Learning and Regular Expression Objects, we can easily verify the legality of various data.
First, let's understand what exactly is a regular expression object of VBScript. Let's first look at a program:
Function CheckExp(patrn, strng)
Dim regEx, Match ' Create variable.
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = patrn ' Set mode.
regEx.IgnoreCase = true ' Set whether character case sensitive.
regEx.Global = True ' Set global availability.
Matches = regEx.test(strng) ' Perform a search.
CheckExp = matches
End Function
In this program, we see that New RegExp can be used to get a regular expression object, and then the object is assigned a regular matching template, that is, telling the regular expression object what kind of template you want to match, and then use the method Test to detect whether the data to be processed matches the template we gave. If it does not match, it means that the data to be processed is not legal data, which realizes the verification of data legality. We can see that using a properly designed matching template, we can easily verify a batch of data information in a format.
Of course, there are many other methods and properties of regular expression objects in VBScript 5.0, such as method Replace(). Using it, we can quickly implement the fashionable UBB style forum and BBS online. This is not within the scope of our discussion. We will discuss it later. Let's take a look at the commonly used methods and properties of regular expression objects in data verification:
Common methods: Execute method
Description: Perform a regular expression search on the specified string.
Syntax: object.Execute(string) The syntax of the Execute method includes the following parts:
object: Required. Always the name of a RegExp object.
string: Required. The text string on which the regular expression is to be executed.
Description: The design pattern of regular expression search is set through the pattern of the RegExp object. The Execute method returns a
Matches collection that contains each matching Match object found in string. If no match is found, Execute returns an empty Matches collection.
Test method
Description: Performs a regular expression search on the specified string and returns a Boolean value indicating whether a matching pattern was found.
Syntax: object.Test(string)
The syntax of the Test method includes the following parts:
object: Required. Always the name of a RegExp object.
string: Required. The text string to perform a regular expression search.
Note: The actual pattern of regular expression search is set through the Pattern property of the RegExp object. The RegExp.Global property has no effect on the Test method. If a matching pattern is found, the Test method returns True; otherwise, it returns False.
Common properties: Global properties
Description: Sets or returns a Boolean value that indicates whether the pattern matches all or only the first one during the entire search string.
Syntax: object.Global [= True | False ]
The object parameter is always a RegExp object. If the search is applied to the entire string, the Global property has a value of True, otherwise its value is False. The default setting is True.
IgnoreCase attribute
Description: Sets or returns a Boolean value indicating whether the mode search is case sensitive.
Syntax: object.IgnoreCase [= True | False ]
The object parameter is always a RegExp object. If the search is case sensitive, the IgnoreCase property is False; otherwise, True. The default value is True.
Pattern properties
Description: Sets or returns the regular expression pattern being searched. This is the most important attribute, and we mainly set this attribute to achieve data verification.
Syntax: object.Pattern [= searchstring]
The syntax of the Pattern property contains the following parts:
object: Required. Always a RegExp object variable.
searchstring: optional. The regular string expression being searched. It may contain various regular expression characters set in a partial table.
Settings: Special characters and sequences are used when writing patterns for regular expressions. The following table describes the characters and sequences that can be used and gives examples.
Character Description: /: Mark the next character as a special character or literal value. For example n matches the character n. /n matches the newline character. The sequence //matches /, /(matches (matches).
^: Match the start position of the input.
$: Match the end of the input.
*: Match the previous character zero or several times. For example, zo* can match z and zoo.
: Match the previous character once or more times. For example, zo can match zoo, but not z.
Share: How to use ASP to handle multi-keyword query In web development, I often encounter multiple keyword pairs of single field queries, which I usually implement through dynamic arrays. Of course, multiple keywords are generally separated by spaces or,. I assume that multiple keywords are separated by spaces, the keyword string is keyStr, and the specific code is
4 pages in total Previous page 1234Next page