RegexpGarden










- Garden Text Representation
12345
let garden = [
"Rosemary", "Primrose", "Rose",
"Christmas Rose",
"Rose-of-Sharon"
];
- Code Editor
- Log
123456
for (const plant of garden) {
if (plant.match(//i) {
water(plant);
}
}
Lesson task •
Water plants plants starting with not "r"
Single character not from a custom symbol class
[^...]
Matches single character NOT from the specified range of symbolsTo make a symbol class blacklist instead of whitelist, start a symbol class with ^:
1234567891011
console.log(!!"0".match(/[^0-46-9]/)) // false
console.log(!!"1".match(/[^0-46-9]/)) // false
console.log(!!"2".match(/[^0-46-9]/)) // false
console.log(!!"3".match(/[^0-46-9]/)) // false
console.log(!!"4".match(/[^0-46-9]/)) // false
console.log(!!"5".match(/[^0-46-9]/)) // true
console.log(!!"6".match(/[^0-46-9]/)) // false
console.log(!!"7".match(/[^0-46-9]/)) // false
console.log(!!"8".match(/[^0-46-9]/)) // false
console.log(!!"9".match(/[^0-46-9]/)) // false
console.log(!!"-".match(/[^0-46-9]/)) // true