How would you split Regex subexpression matches in to multi-dimensional string arrays?
I have a \"myvar\" string of:
1-4:2;5-9:1.89;10
var r = /(\d+)[-+](\d*):(\d+\.?\d*);?/g;
var s = "1-4:2;5-9:1.89;10-24:1.79;25-99:1.69;100-149:1.59;150-199:1.49;200-249:1.39;250+:1.29";
var match;
while ((match = r.exec(s)) != null) {
console.log("From " + match[1] + " to " + match[2] + " is " + match[3]);
}
The console.log() call is a Firefox/Firebug call. You can of course use alert(), document.write() or whatever else suits.
See RegExp object reference, in particular the RegExp methods, most notably RegExp.exec().