const str = 'hello world!';
const result = /^hello/.test(str);
console.log(result); // true
/**
The test() method executes a search for a match between
a regular expression and a specified string
*/
// .test(string) is a method of the RegExp class
// returns a boolean value
// .match(regexp) is a method of the String class
// if global flag (g) is included, returns an array of matched instances
const str = "A text string!";
const reg = /t/g; // matches all lower case "t"s
reg.test(str); // returns true
str.match(reg); // returns ['t', 't', 't']
let text = "abcdefghijklmnopqrstuvxyz";
let pattern = /e/;
pattern.test(text)
/*searches for pattern in text*/