Example of Split function in ASP

xiaoxiao2021-03-06  35

Example of Split function in ASP

Author: Shuai frog Time: 2003-9-14 Document Type: Original from: Blue ideal view statistics total: 12364 | year: 280 | Quarter: 280 | Month: 280 | Week: 108 | today: 14

Everyone has encountered some values ​​in a string to take a string? Do you feel that reading or textbooks have a confused split's writing. If you have any questions, please see the explanation of the example below, I believe you will have a certain understanding of this. I will introduce the usage of the split function: Return Value array = Split ("string", "split") assumes that the variable StrURL saves the URL value, such as strurl = "ftp: // username: password @ Server", this is What should we do if we log in to the FTP on the FTP in the IE. If we want to take it out of usrname and password? Of course, there are many ways to solve, where we only describe how to solve with splits. First, we find the split. We have found that there is a colon between UserName and Password, so we use this colon as a "split" of the split function to divide the entire string, and finally reach the purpose of UserName and Password. . The code is as follows: strurl = "ftp: // username: password @ server" Aryreturn = Split (Strurl, ":") So we will split the character series colon, and the result is saved in Aryreturn (Aryreturn is a Array). Let's take a look at this final result, because the split function ends back to an array, so we mainly show the elements in the array, and to involve some functions related to the number of groups: Isarray () Judging whether the array The function, LBound () takes the subscript of the group, Ubound () takes the subscript of the group. Response.write ("Return value is an array:" & Isarray (Aryreturn) & "
") for i = lbound (aryreturn) to Ubound (Aryreturn) Response.write ("Elements in Return Value [" & I & "]:" & Right (Aryreturn (I), LEN (Aryreturn (i)) - 2) & "
") Next By the above code, we see the string is split into three parts, ie : "FTP", "// username", "password @ server". We have to take further processing, I don't have much to say, directly to the code. Take UserName code: strusename = right (Aryreturn (1), LEN (Aryreturn (1)) - 2) Take Password's code: 'Take Password We use the split function, but this returned division is "@" AryTemp = Split (Aryreturn (2), "@") strpassword = arytemp (0) 'We can remove the ServersTrServer = AryTemp (1) split can be a character, or a string.

转载请注明原文地址:https://www.9cbs.com/read-65712.html

New Post(0)