[jQuery] Re: Using jQuery to parse a string

2007-08-10 Thread Andy Matthews
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

[jQuery] Re: Using jQuery to parse a string

2007-08-10 Thread Sean Catchpole
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 >

[jQuery] Re: Using jQuery to parse a string

2007-08-10 Thread Andy Matthews
: 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

[jQuery] Re: Using jQuery to parse a string

2007-08-10 Thread Sean Catchpole
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

[jQuery] Re: Using jQuery to parse a string

2007-08-10 Thread Andy Matthews
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]; });

[jQuery] Re: Using jQuery to parse a string

2007-08-10 Thread Sean Catchpole
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

[jQuery] Re: Using jQuery to parse a string

2007-08-10 Thread cfdvlpr
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(/^.*\./,'')

[jQuery] Re: Using jQuery to parse a string

2007-08-10 Thread Andy Matthews
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