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!