Examples of Split string functions in ASP

Source: Internet
Author: User

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

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.