Answers for "Regex match entire words only js"

6

Regex match entire words only js

let string = "Hello world"; // you can use .toLowerCase() to check only in lower

let match = "world"; // word to match

let regex = new RegExp('\\b('+match+')\\b');

console.log('true for no match, false for match');
console.log(string.match(regex) == null); //.match() returns array of words found

// true for no match, false for match
// false
Posted by: Guest on October-14-2021

Code answers related to "Regex match entire words only js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language