RegexpGarden










- Garden Text Representation
12345
let garden = [
"Rosemary", "Apple 'Gala Must 696'",
"Primrose", "Echinacea 'Sunrise'",
"Rose"
];
- Code Editor
- Log
123456
for (const plant of garden) {
if (plant.match(//i) {
water(plant);
}
}
Lesson task •
Water plants which names end with non-word character
Any single non-word character
\W
Matches single character, that is not letter, number or underscore123456
console.log(!!"foo$".match(/foo\W/)) // true
console.log(!!"foo*".match(/foo\W/)) // true
console.log(!!"foo_".match(/foo\W/)) // false
console.log(!!"foobar".match(/foo\W/)) // false
console.log(!!"foo42".match(/foo\W/)) // false
console.log(!!"foo".match(/foo\W/)) // false