A pot
Rose
A pot
Rue
A pot
Rice
A pot
Rye
1
let garden = ["Rose", "Rue", "Rice", "Rye"];
123456
for  (const plant of garden) {
if (plant.match(//i) {
cut(plant);
}
}
Lesson 4 / 42

Lesson task •

Cut "Rose" and "Rice", but not the other plants

Any single character

. again

Matches any single symbol

You can combine multiple gutshots in one regular expression at any positions:

123
console.log(!!"bar".match(/.a./)) // true 
console.log(!!"baz".match(/.a./)) // true 
console.log(!!"foo".match(/.a./)) // false 

Please note, that if you want to match "." literally, you should escape it with backslash \:

12345
console.log(!!"foo.bar".match(/\.bar/)) // true 
console.log(!!"bar".match(/\.bar/)) // false 
console.log(!!"4.2".match(/\.2/)) // true 
console.log(!!"4.4".match(/\.2/)) // false 
console.log(!!"42".match(/\.2/)) // false