js regex return null
if(!new RegExp(regex).test(value)){ alert('Your string was invalid.'); }
Here is what the above code is Doing:
1. The first line creates a new regular expression object.
2. The second line tests the regular expression against a string.
3. The third line alerts the user if the string was invalid.