var dateRegex = /\/Date\((\d+)\)\//g; // [0-9] instead of \d does not help.
dateRegex.test("/Date(1286443710000)/"); // true
dateRegex.test("/Date(1286445750000)/"); // false
Both Chrome and Firefox JavaScript consoles confirm. What the hell, guys?
Edit: even simpler test case:
var dateRegex = /Date\(([0-9]+)\)/g;
dateRegex.test("Date(1286445750000)"); // true
dateRegex.test("Date(1286445750000)"); // false
dateRegex.test("Date(1286445750000)"); // true
dateRegex.test("Date(1286445750000)"); // false
dateRegex.test("Date(1286445750000)"); // true
This shows that it alternates true/false every time…
In your case remove the
gmodifier from the end, for example:It’s a bug with the way regexes are implemented in ECMAScript 3, there’s a great post on the details here.