Javascript Regular Expressions Match word start and end
let cookbookString = new Array(); cookbookString[0] = "Joe's Cooking Book"; cookbookString[1] = "Sam's Cookbook"; cookbookString[2] = "JavaScript CookBook"; cookbookString[3] = "JavaScript BookCook"; cookbookString[4] = "cookBook BookCook"; cookbookString[5] = "COOKBOOK cookbook"; // search pattern let pattern = /Cook.*Book/; for (let i = 0; i < cookbookString.length; i++){ console.log(cookbookString[i] + " " + pattern.test(cookbookString[i])); }