RegexpGarden












- Garden Text Representation
123456
let garden = [
"Primrose",
"Apple 'Gala Must 696'",
"Rosemary", "Tomato 'Roma VF1'",
"Roseberry", "Corn 'Pioneer 3751'"
];
- Code Editor
- Log
123456
for (const plant of garden) {
if (plant.match(//i) {
fertilize(plant);
}
}
Lesson task •
Fertilize plants that has no digits in their names
Any single non-digit character
\D
Matches any single non-digit character1234
console.log(!!"foo".match(/\D/)) // true
console.log(!!"42".match(/\D/)) // false
console.log(!!"foobar".match(/foo\D/)) // true
console.log(!!"foo42".match(/foo\D/)) // false