Javascript Regular Expressions Match word start and end ignoring case

Description

Javascript Regular Expressions Match word start and end ignoring case


let cookbookString = new Array();

cookbookString[0] = "Joe's Cooking Book";
cookbookString[1] = "Sam's Cookbook";
cookbookString[2] = "JavaScript CookBook";
cookbookString[3] = "JavaScript cookbook";

// search pattern
let pattern = /Cook.*Book/i;
for (let i = 0; i < cookbookString.length; i++){
  console.log(cookbookString[i] + " " + pattern.test(cookbookString[i],i));
}



PreviousNext

Related