Match specific word in regex in JavaScript?

JavascriptWeb DevelopmentFront End TechnologyObject Oriented Programming

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
raja
Published on 24-Oct-2020 12:34:17
Advertisements