📌  相关文章
📜  匹配字符串 js 中的单词 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:23.010000             🧑  作者: Mango

代码示例1
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