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
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>
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 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();
4 matches
Mail list logo