To match specific word in regex, use use regular expression.
Example
Following is the code −
var sentence = "This is the not javascript Tutorial"; var regularExpression = /\bjavascript\b/g; var output = regularExpression.test(sentence); console.log(output);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo308.js.
Output
This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo308.js true