RegexpGarden








- Garden Text Representation
12345
let garden = [
"Rose", "Rosemary",
"Roseberry",
"Primrose"
];
- Code Editor
- Log
123456
for (const plant of garden) {
if (plant.match(//i) {
water(plant);
}
}
Lesson task •
Water plants having one or more letters after "rose"
At least once
+
Repeats the previous token one or more times123
console.log(!!"foo42bar".match(/^foo\w+bar$/)) // true
console.log(!!"foo4bar".match(/^foo\w+bar$/)) // true
console.log(!!"foobar".match(/^foo\w+bar$/)) // false
If you want to match "+" literally, escape it with backslash:
1
console.log(!!"+".match(/\+/)) // true