I've come across something a weird (at least it is to me), this is a simplified version of my problem
var $value = 123321;
var hex = /(?:[0-9a-fA-F]{3}){1,2}/g;
var valid = (hex.test($value));
console.log(valid); // Outputs true.
valid = hex.test($value);
console.log(valid); // Outputs false.
Why does it give me 2 different outputs from running the same command twice?
Here's a JSFiddle to an example too, http://jsfiddle.net/wsu9xdv6/