[jQuery] Re: How to deterine number of words in a string?

2009-07-28 Thread CarComplaints.com
Hi Conrad, for that to work, I think you'd need to figure out the character code range of all the Chinese letters that might be included, & then include them as a range in the regular expression. var string = 'I come from 香港'; var mresult = string.match(/\w+|[\u4e00-\u9fa5]/g); alert(mresult.len

[jQuery] Re: How to deterine number of words in a string?

2009-07-25 Thread CarComplaints.com
With regular expressions, it's simpler than all this .. you can count letter groups that are split up by anything that's not a letter or a digit. var string = $("span.string").text(); var mresult = string.match(/\w+/g); alert(mresult.length); On Jul 24, 8:41 pm, Lukas Lt <1luk...@gmail.com>

[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-18 Thread CarComplaints.com
I'll second the JSON suggestion. Assuming from your XML code example that you're only ever going to have day/show nodes, here's the JSON: { 'Monday' : [ { time : "0800-1000", dj : "mc funk", name : "nonstop music" }, { time : "1000-1200", dj : "mc rap", name : "nonstop music" } ],

[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-18 Thread CarComplaints.com
jQuery selectors take an optional 2nd parameter to provide a search context (object to search through). Pretty minor but it reduces the code nicely... you can get rid of the 3 find()'s. var time = $('time',this).text(); var dj = $('dj',this).text(); var showname = $('showname',this).text();