Take the g
out
var reIsNumeric = /[0-9]/;
console.log(reIsNumeric.test(1)); // true
console.log(reIsNumeric.test(2)); // true
console.log(reIsNumeric.test(3)); // true
console.log(reIsNumeric.test(4)); // true
http://jsfiddle.net/0tap3nfx/1/
The reason is because the g
modifier is used to perform a global match (find all matches rather than stopping after the first match).
So basically the value that will return true is not what you would expect but the same regex as yours does work as expected see below.
var reIsNumeric = /[0-9]/g;
console.log(reIsNumeric.test(1)); // true
console.log(reIsNumeric.test(22)); // true
console.log(reIsNumeric.test(333)); // true
console.log(reIsNumeric.test(4444)); // true
http://jsfiddle.net/0tap3nfx/2/