RegexpGarden














- Garden Text Representation
1234567
let garden = [ "Apple 'Gala Must 696'", "Corn 'Pioneer 3751'", "Christmas Rose", "Primrose", "Tomato 'Roma VF1'", "Rosemary", "Wheat 'Norin 10'"];- Code Editor
- Log
123456
for (const plant of garden) {if (plant.match(//i) {water(plant);}}Lesson task •
Water all the plants that has digits in their names
Any single digit character
\d
Matches any single digit character1234567891011
console.log(!!"foo42".match(/\d/)) // true console.log(!!"foo".match(/\d/)) // false console.log(!!"foo42".match(/foo\d/)) // true console.log(!!"foo$".match(/foo\d/)) // false console.log(!!"foo42".match(/\d$/)) // true console.log(!!"foo$".match(/\d$/)) // false console.log(!!"foo".match(/\d$/)) // false console.log(!!"foo42".match(/\w\d/)) // true console.log(!!"foo$".match(/\w\d/)) // false console.log(!!"foo 42".match(/^\w\w\w\s\d\d$/)) // true console.log(!!"bar 42".match(/^\w\w\w\s\d\d$/)) // true 