RegexpGarden








- Garden Text Representation
12345
let garden = [	"Blackberry", 	"Heliopsis helianthoides", 	"Rosemary", "Primrose"];- Code Editor
- Log
123456
for  (const plant of garden) {if (plant.match(//gi) {water(plant);}}Lesson task •
Water a plant that has a recurring pattern of 4 or more letters in its name
Recurring Capturing group
\N
Matches the text captured with the N'th capturing groupYou may define a pattern where some text is repeating word-by-word throughout the string. Once captured, the text in a capturing group can be then referenced in a regular expression with \N where N is an order of the capturing group numbered from 1. E.g. \1 will match literally the text captured with the first capturing group:
12345
console.log(!!"foo foo".match(/(\w*)\s\1/gi)) // true console.log(!!"bar bar".match(/(\w*)\s\1/gi)) // true console.log(!!"foo bar".match(/(\w*)\s\1/gi)) // true console.log(!!"foo bar foo bar".match(/(\w*)\s(\w*)\s\1\s\2/gi)) // true console.log(!!"foo foo bar bar".match(/(\w*)\s(\w*)\s\1\s\2/gi)) // false 