regex.test(str);
is the thing you want to check. It looks in str
if it is mathing regex
, true
if it does, else false
var a = "hey";
var b = "h~y";
var c = "he’";
var reg = /[’~]/ ;
console.log(reg.test(a)); // false
console.log(reg.test(b)); // true
console.log(reg.test(c)) // true
solved Regular expression match in javascript on a list of items