คำอธิบาย
ใช้ Regular Expression ด้วย word boundary (\b) เพื่อจับคู่คำที่ต้องการอย่างแม่นยำ
ตัวอย่างโค้ด
var sentence = "This is the not javascript Tutorial"; var regularExpression = /\bjavascript\b/g; var output = regularExpression.test(sentence); console.log(output);
วิธีรัน
node fileName.js
ผลลัพธ์
true