www.webdeveloper.com
Results 1 to 3 of 3

Thread: Parsing key:value pairs into an array.

  1. #1
    Join Date
    Jan 2004
    Posts
    3

    Question Parsing key:value pairs into an array.

    Help. I'm having trouble with this one:

    Using JavaScript, please parse the following string of semi-colon
    delimited key:value pairs and populate the results into an array:

    "inning1:0;inning2:0;inning3:1;inning4:3;inning5:0;inning6:1;inning7:0;inning8:0;inning9:1"
    Thanks,
    SB

  2. #2
    You could try this:
    split_val=string_name.split(";")

    string_name would be the name of the variable that contains the values you want to split up when it encounters a semicolon. To reference the first value you would do this:
    split_value[0]

    Second value: split_value[1]... etc.

  3. #3
    Join Date
    Jan 2004
    Posts
    3
    Is the syntax on this code correct?

    <BEGIN CODE>
    SUBSplit() {
    string1 = "inning1:0;inning2:0;inning3:1;inning4:3;inning5:0;inning6:1;inning7:0;inning8:0;inning9:1"
    split (string1, group1[]){
    for (i=0; i<(size(group[]); i++){
    split (group[i], elements);
    FinalArray[i] = elements[0,1]
    }
    }
    }

    <END CODE>
    Thanks,
    SB

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles