js regex retorna nulo

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