The use of the Split function in ASP
Split intercept string
Just look at a few examples to understand.
Copy Code code as follows:
Mystr= "1,2,3,4,5"
Mystr=split (MyStr, ",")
For i=0 to UBound (MYSTR)
Response.Write MyStr (i)
Next
' The 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 is xlei.net/x/index.asp
Mystr= "1 batches in 2 batches in 3 batches in 4 batches in 5 batches in"
Mystr=split (mystr, "batch in")
For i=0 to UBound (MYSTR)
Response.Write MyStr (i)
Next
' The return value is 1234 batches in 56
Describe
Returns a one-dimensional array based on 0 that contains the specified number of substrings.
Grammar
Split (expression[, delimiter[, count[, start]])
The syntax of the Split function has the following parameters:
Parameter description
Expression must be selected. A string expression that contains substrings and delimiters. If expression is a zero-length string, Split returns an empty array, which is an array that contains no elements and data.
Delimiter optional. The character used to identify the bounds of the substring. If omitted, use a space ("") as the separator. If delimiter is a zero-length string, returns the set of cell numbers that contain the entire expression string.
Count is optional. The number of substrings returned,-1 indicates that all substrings are returned.
Compare optional. Indicates the numeric value of the comparison type to use when calculating the substring. For numeric values, see the "Settings" section.
Set up
The Compare parameter can have the following values:
Constant numerical description
Vbbinarycompare 0 performs binary comparisons.
vbTextCompare 1 performs a text comparison.
Vbdatabasecompare 2 performs a comparison based on the information contained in the database (performing comparisons in this database).
Reference from ASP side to verify that illegal characters are included
Copy Code code 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 illegal 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 illegal characters! '); History.back () </script> "
Response.End
End If