Example of use of split in ASP

Source: Internet
Author: User
Tags ftp string split
Example |split have you ever come across a string that you want to get some value from? 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.

For example, I want to get an FTP username and password (server, etc.) value ( using IE when FTP or from the table to remove the value of FTP)。
Here is my solution:
Set URL to receive the URL value, here refers to: Url=ftp://username:password@server, please pay attention to this dark tomb?br> I think we all see this URL in the law, it is each part is ":" to the area divided into three parts, namely: FTP,//username, Password@server
First, separate the parts of the URL, using split (URL, ":")
The following are the specific code:

Parts = Split (URL, ":") ' parts has three parts at this time, parts (0) =ftp,parts (1) =//username,parts (2) =password@server
' Next remove the information that is not used
' Because only take username, so parts (0) and parts (2) are useless, directly do not quote!
Newname=replace (Parts (1), "//", "") ' remove//symbol, as this is not the content of username
' At this point the newname is both a user name.


The above is to take the user name code, if you want to take the password again, you can refer to the following.

' Because the username belongs to parts (2) and contains information about the server, if you do not take the server:
Newpass = Left (Parts (2), InStr (Parts (2), "@"-1) " takes value to the number of digits before @.
At this point the newpass is taken as a password


The above code is not to take the server address code, if you have access to the server, in fact, is very simple

Newparts=split (Parts (2), "@") ' at this time newparts divided into two parts: newparts (0) is the password, that is, password;newparts (1) is the server address, that is,
' If you want to output the password, Direct Response.Write newparts (0) on it, the server newparts (1)


Something, in order to take a string of certain characters or parts, as long as the grasp of the law, coupled with split can be very good to make a variety of effects. Write this article, I hope to help you learn, but also hope that the road Master can guide twos!

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.