I'm wondering if this is possible. I'm trying to iterate over an object containing regex expressions as below:
var formats = {
AUS:"/^\D*0(\D*\d){9}\D*$/",
UK: "/^\D*0(\D*\d){9}\D*$/"
};
var matched = false;
for (var i in formats) {
if (!matched) {
var format = formats[i];
matched = value.match(formats[i]);
}
}
I appreciate both AUS & UK expressions are the same value but this is just to prove the concept.
the value I'm matching is 0423887743 and it works when i do the following:
value.match(/^\D*0(\D*\d){9}\D*$/);