RegexpGarden












- Garden Text Representation
12345
let garden = [ "Rue", "Rose", "Rye", "Rosemary", "Rice", "Primrose"];- Code Editor
- Log
123456
for (const plant of garden) {if (plant.match(//i) {water(plant);}}Lesson task •
Water every plant, containing "rose" at any place and case
flag i
Makes regular expression case insensitiveTo make regular expression case insensitive one should use a special flag - i - after the main pattern of the regexp:
12
console.log(!!"Foo Bar".match(/foo/)) // false console.log(!!"Foo Bar".match(/foo/i)) // true Note: from here on all the regular expressions will include this flag, beware.
