var t = "";
var a = ["atom-required","atom-label","atom-data-type","atom-regex"];
var r = /atom\-(label|required|regex|data\-type|class|is\-valid|field\-value|error)/i;
function test(a, r){
for(var i = 0; i<a.length; i++){
t += a[i] + " => " + r.test(a[i]) + "<br/>";
}
}
test(a, r);
t += "<br/>";
a = ["atom-required","atom-label","atom-data-type","atom-regex"];
var r = /atom\-(label|required|regex|data\-type|class|is\-valid|field\-value|error)/gi;
test(a, r);
$("#results").get(0).innerHTML = t;
当不指定 g 时,它可以正常工作,
atom-required => true
atom-label => true
atom-data-type => true
atom-regex => true
当指定 g 时,它会交替工作
atom-required => true
atom-label => false
atom-data-type => true
atom-regex => false