K...That's what I thought. Thanks.
_
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Sean Catchpole
Sent: Friday, August 10, 2007 4:06 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Using jQuery to parse a string
Just the current item.
If your
he current item?
>
> --
> *From:* jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] *On
> Behalf Of *Sean Catchpole
> *Sent:* Friday, August 10, 2007 3:35 PM
> *To:* jquery-en@googlegroups.com
> *Subject:* [jQuery] Re: Using jQuery to parse a string
>
: Using jQuery to parse a string
Quick:
x is each item of the array.
Short:
$.each is similar to Array.map
$.each calls the function for each item in the array. If the function
returns false then it stops.
This is different from a map function in that a map function will replace
the value in the array
Quick:
x is each item of the array.
Short:
$.each is similar to Array.map
$.each calls the function for each item in the array. If the function
returns false then it stops.
This is different from a map function in that a map function will replace
the value in the array with what is returned by the
PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Using jQuery to parse a string
Hi, This might be a fancier solution:
var s = "title.string1-color.string2-size.string3";
h={};
$.each(s.split('-'),function(x){
var t = x.split('.');
h[ t[0] ] = t[1];
});
Hi, This might be a fancier solution:
var s = "title.string1-color.string2-size.string3";
h={};
$.each(s.split('-'),function(x){
var t = x.split('.');
h[ t[0] ] = t[1];
});
~Sean
On 8/10/07, cfdvlpr <[EMAIL PROTECTED]> wrote:
>
>
> That's just the kind of help I needed. Here's what I hav
That's just the kind of help I needed. Here's what I have now that
works perfectly:
var sArr = s.split('-');
h = {};
h['title'] = sArr[0].replace(/^.*\./,'');
h['color'] = sArr[1].replace(/^.*\./,'')
You could split the string on ".". That would create an array which you
could then do things with:
var s = 'title.string1-color.string2-size.string3';
Var sArr = s.split('.');
Alert(sArr);
Returns "title,string1-color,string2-size,string3"
-Original Message-
From: jquery-en@googlegroup
8 matches
Mail list logo