Javascript String scan(re)
String.prototype.scan = function (re) { if (!re.global) throw "RegExp should be global"; var s = this; var m, r = []; while (m = re.exec(s)) { m.shift();/* w w w . j a va 2 s . c o m*/ r.push(m); } return r; };