Split function in ASP examples

  We have come across a string in order to take some value from the start without?    Have read or materials that the wording of the split muddle…… If there is such a doubt, take a look at the examples below, I explained, I believe that you will have some understanding of this. 

  Let me first tell us about the use of Split function: 
  Split return value = array ( "string", "Partition Fu") 

  StrURL assumptions preserved URL variable values, such as strURL = "ftp://username:password @ server," This is what we in IE to log in to the FTP on the URL, which if we want to take the username and password out of , how do?    Of course there are many ways to resolve, and here we have only introduced the use of Split to the solution.    First, we have to find separate website.    We have found that in this string, between the username and password have a colon to separate them, so we put this colon Split function as a "segmentation Fu" to split the entire string, ultimately achieving username and password from the purpose of .    Code as follows: 
  StrURL = "@ server ftp://username:password" 
  AryReturn = Split (strURL ,":") 

  We put this string separated by colons, and the results of the preservation division in aryReturn (aryReturn is an array). 

  Below we take a look at the final outcome of this bar, because Split function eventual return is an array, we show that the main elements of the array, we must relate to some of the array with the function: IsArray () judgement whether the array function, LBound () from the array subscript, UBound () from the array superscript. 

  Response.Write ( "return value is an array:" & IsArray (aryReturn) & "<br>") 
  For i = LBound (aryReturn) To UBound (aryReturn) 
  Response.Write ( "return value of the array element [" i & & ":" & Right (aryReturn (i), Len (aryReturn (i)) -2) & "<br>") 
Next

  Through the above code, we can see that the string cut into three parts, namely: "ftp ","// username", "password @ server."    We have to take username and password needed further treatment, I will not say more, given the code directly. 
  Admission username code: 
  StrUsername = Right (aryReturn (1), Len (aryReturn (1)) -2) 
  Admission password code: 

  'We also use password from Split function, but at this time the division is "@" 
  AryTemp = Split (aryReturn (2 ),"@") 
  StrPassword = aryTemp (0) 
  'We can be the way out server 
  AryTemp strServer = (1) 

  Segmentation is a character can address, and can also be a string.    Such as: 
  AryReturn = Split ( "ftp://username:password @ server ,"//") 

  NOTE: 
  1. Generally speaking, ASP can be no statement variables, the use of Split function, and if the return value to declare variables, it can only use Dim, can not be Redim.    Though it is said that their return is an array should be used Redim can, but in the actual process of using it is not enough.    I do not know how the case? 
  2 If you use Split function to a separate string does not exist at the division, will return to the entire string, and the results are only one element of the array. 

  After then, to take a string of characters or in part, as long as it seizes laws, coupled with the split on the use of effects can be well made.    Write this book, we hope to be helpful to the study, we also hope to the guidance of experts from all January 2! 

Bookmark it: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • DotNetKicks
  • DZone
  • Furl
  • Netvouz

Tags: ,

Releated Articles


0 Comments to “Split function in ASP examples”

No Comments. Send your comment.

Leave a Reply

You must be logged in to post a comment.