Sean...
 
I have a question...when you pass in X to the anonymouse function on the 3rd
line, what is x? Is it $(this), a jQuery object? How do you know what it is?

  _____  

From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Sean Catchpole
Sent: Friday, August 10, 2007 2:39 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];
});


~Sean



On 8/10/07, cfdvlpr <[EMAIL PROTECTED]  <mailto:[EMAIL PROTECTED]> >
wrote: 


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(/^.*\./,''); 
                        h['size'] = sArr[2].replace(/^.*\./,'');




Reply via email to