Use of the Split function in ASP
Split string
Let's look at several examples.
Copy codeThe Code is as follows: mystr = "1, 2, 3, 4, 5"
Mystr = split (mystr ,",")
For I = 0 to ubound (mystr)
Response. write mystr (I)
Next
'Return value is 123456
Mystr = "xlei.net/http/student/x/index.asp"
Mystr = split (mystr, "/http/student ")
For I = 0 to ubound (mystr)
Response. write mystr (I)
Next
'Return value: xlei.net/x/index.asp
Mystr = "1 batch in 2 batch in 3 batch in 4 batch is in 5 batch in"
Mystr = split (mystr, "batch in ")
For I = 0 to ubound (mystr)
Response. write mystr (I)
Next
'The returned value is 1234 batches in 56
Description
Returns a zero-dimensional array containing a specified number of substrings.
Syntax
Split (expression [, delimiter [, count [, start])
The syntax of the Split function includes the following parameters:
Parameter description
Expression is required. A string expression that contains a substring and a separator. If expression is a zero-length string, Split returns an empty array, that is, an array that does not contain elements and data.
Delimiter is optional. Character used to identify the substring boundary. If omitted, use space ("") as the separator. If delimiter is a zero-length string, a single element array containing the entire expression string is returned.
Count is optional. Number of substrings to be returned.-1 indicates that all substrings are returned.
Compare is optional. Indicates the value of the comparison type used to calculate the substring. For values, see the "Settings" section.
Set
The compare parameter can have the following values:
Constant Value description
VbBinaryCompare 0 performs binary comparison.
VbTextCompare 1 performs text comparison.
VbDatabaseCompare 2 compares the information contained in the database.
Reference from asp side to verify whether it contains invalid characters
Copy codeThe Code is as follows: username = replace (trim (request. form ("username ")),"'","''")
Password = replace (trim (request. form ("password ")),"'","''")
If instr (username, "%") or instr (username, "#") or instr (username ,"? ") Or instr (username," | ") then
Response. write "<script. language = javascript> alert ('your name contains invalid characters! '); History. back () </script>"
Response. end
End if
If instr (password, "%") or instr (password, "#") or instr (password ,"? ") Or instr (password," | ") then
Response. write "<script. language = javascript> alert ('your password contains invalid characters! '); History. back () </script>"
Response. end
End if