Consider the following snippet:
var regex = /^\d+$/; // equivalent to new RegExp('^\\d+$');
console.println(regex.test('000'));
console.println(regex.test('abc0'));
console.println(regex.test('ddd'));
One would expect the output to be:
true
false
false
However, when I run it on Adobe Acrobat X, which runs JavaScript 1.8, it outputs:
false
false
true
What’s going on here?
It’s likely a result of string processing on the way to the Javascript interpreter, causing your
\dto be interpreted asd. An extra backslash (apparently) does the trick.