Instance usages of Split split string function in ASP _asp Foundation

Source: Internet
Author: User
Tags numeric numeric value

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

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.