The usage of Split function in ASP, use split to split and intercept strings, and you can understand it by looking at a few examples.
Usage of Split function in ASP
Split and intercept string
Just look at a few examples to understand
Copy the code as follows:mystr=1,2,3,4,5
mystr=split(mystr,,)
for i=0 to ubund(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 ubund(mystr)
response.write mystr(i)
next
'Return value is xlei.net /x/index.asp
mystr=1 batch in 2 batches in 3 batches in 4 batches is in 5 batches in
mystr=split(mystr, batch in)
for i=0 to ubund(mystr)
response.write mystr(i)
next
'The return value is 1234 batches at 56
Description
Returns a one-dimensional array based on 0, containing the specified number of substrings.
Syntax
Split(expression[, delimiter[, count[, start]]]])
The syntax of the Split function has the following parameters:
Parameter description
expression Required. A string expression containing substrings and separators. If expression is a zero-length string, Split returns an empty array, that is, an array that does not contain elements and data.
Delimiter optional. Characters used to identify the limits of substrings. If omitted, use space() as the delimiter. If the delimiter is a zero-length string, a single-element array containing the entire expression string is returned.
count is optional. The number of substrings returned, -1 indicates that all substrings are returned.
compare Optional. Indicates the value of the comparison type used when calculating the substring. For values, see the Settings section.
Setting
the compare parameter can have the following values:
Constant value description
vbBinaryCompare 0 Perform binary comparison.
vbTextCompare 1 Perform text comparison.
vbDatabaseCompare 2 performs a comparison based on the information contained in the database (in which comparison is performed).
Quote from asp to verify whether it contains illegal characters
Copy the 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