The split () method of the address URL is used;

Source: Internet
Author: User

Stringobject.split (separator,howmany)
Parameters Description
Separator Necessary. A string or regular expression that splits stringobject from where specified by the parameter.
Howmany Optional. This parameter specifies the maximum length of the returned array. If this parameter is set, the returned substring will not be more than the array specified by this parameter. If this argument is not set, the entire string is split, regardless of its length.
1 //Get the parameters in the URL 2 GetParam (); 3     function GetParam () {4        C1 = Window.location.href.split ("?") [1]; GetID5        id = c1.split ("&") [1].split ("=") [1];//Get the value of ID 6         id = id.lastindexof ("#")! =-1? Id.split ("#") [0]: ID; 7         Toolsceneid = C1.split ("&") [0].split ("=") [1];//Get the value of ID 8     }

The split () method splits the specified string by a specified delimiter, which splits into an array of strings and returns such as: string str = "AA.BB.CC.DD";    string[] Strarray = str. Split ('. '); The results obtained strarray the value of string[]{"AA", "BB", "CC", "DD"} where "AA", "BB", "CC", "DD" is the array of elements that make up arrays strarray each element corresponds to an index value, Just like in a table in a database each row of data records has its own index ID, the index value of the array element is counted from 0, that is, the index value of the first element is 0, followed by 1 we can use the index value of the array to take the value of the array element corresponding to the position, for example, we want to take the first element "Then we can write: string aa = Strarray[0]; here split ('. ') [1] is an abbreviated form, take it apart to see the reality is to first use split ('. ') method to use the string "." Cut to form a string array and then remove the value of the second element in the resulting array by index [1]

The split () method of the address URL is used;

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.