js regex return null

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