function you have encountered to want to take a string of certain values and not to start? Do you feel that reading or teaching material is confused with the writing of split ... If you have this question, please see below my explanation to the example, I believe you will have a certain understanding of this.
Let me introduce the use of the split function:
Suppose the variable strurl save the URL value, such as strurl= "; This is the URL form that we login to FTP on IE, if we want to take out the username and password, what should we do? Of course there are many ways to solve, here we only introduce the method of split to solve. First, we find the separator. We found that in this string, there is a colon separating them from the username and password, so we split the colon as a "split" of the split function, and finally get the username and password. The code is as follows:
So we split the string with a colon, and the split result is saved in Aryreturn (Aryreturn is an array).
Let's take a look at the final result, because the split function eventually returns an array, so the main thing we do is show the elements in the array, and we're going to involve some functions related to the array: IsArray () to determine whether the array functions, LBound () Takes the subscript of an array, UBound () The superscript of the array.
Through the above code, we see that the string is divided into three parts: "FTP", "//username", "Password@server". We want to take username and password need further processing, I will not say more, directly to the code.
Take username code:
Password code:
The code> Separator can be a character or a string. For example: Note: 1. In general, the ASP can not declare variables, use the Split function, if you want to declare the return value of the variable, only can use dim, but can't use ReDim. Although it is said that its return is an array, it should be used ReDim, but in the actual use of the process is not. I don't know what's going on. 2. If the split function is used to split a delimiter that does not exist in a string, the entire string is returned, resulting in an array of only one element.
Something, for certain characters or parts of a string to be taken, just catch the rule, plus split will make a good difference.
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.