FrontendDeveloper.in

JavaScript question detail

How do you search a string for a pattern

You can use the test() method of regular expression in order to search a string for a pattern, and return true or false depending on the result.

var pattern = /you/;
console.log(pattern.test("How are you?")); //true
Back to all JavaScript questions
Get LinkedIn Premium at Rs 399