A pot
Rose
A pot
Rue
A pot
Primrose
A pot
Rye
A pot
Rosemary
12345
let garden = [
	"Rose", "Rue", 
	"Primrose", "Rye", 
	"Rosemary"
];
123456
for  (const plant of garden) {
if (plant.match(//i) {
fertilize(plant);
}
}
Lesson 8 / 42

Lesson task •

Fertilize all the plants consisting of 3 letters

Any single word character

\w

Matches any single latin letter, number or underscore. Note, that the whitespace characters and special characters other than "_" will not be matched by \w

Often you don't know in advance which symbol will be following in the substring you are looking for. The only thing you know is that it will be a word character. In such scenario you may find useful \w:

12
console.log(!!"foo42".match(/foo\w/)) // true 
console.log(!!"foo$".match(/foo\w/)) // false 

Spaces are not covered with \w:

12
console.log(!!"4_2".match(/\w\w\w/)) // true 
console.log(!!"4 2".match(/\w\w\w/)) // false 

Note that one \w stands for one symbol:

1234
console.log(!!"foobar".match(/\w\w\w\w/)) // true 
console.log(!!"foo".match(/\w\w\w\w/)) // false 
console.log(!!"foo".match(/^\w\w\w$/)) // true 
console.log(!!"foo bar".match(/^\w\w\w$/)) // false 

Remember that if you need to match "\" literally, you need to escape it with backslash:

123
console.log(!!"\".match(/^\\/)) // true 
console.log(!!"\w".match(/^\\w/)) // true 
console.log(!!"\w".match(/^\w/)) // false