JS Regex Return Null

if(!new RegExp(regex).test(value)){
    alert('Your string was invalid.');
}
Borma