I have this simple pattern that validate Time - 24 Hours Mode -
var patt = /^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/g;
If i execute this pattern with .test()
method twice i get two different values
Like This
CODE
console.log(patt.test('01:09')); // true
console.log(patt.test('01:09')); // false
i have notice that if i do the following i get the same result :
var patt = /^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/g;
console.log(patt.test('01:09')); // true
var patt = /^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/g;
console.log(patt.test('01:09'));//true
Question
i'll re-initiate the patt
object as a work around in my case but i'm very curious to know what happens
Also i notice that patt
object doesn't change after using it with test()
Method
jsFiddle for those how want to prove something