December 2023
Intermediate to advanced
242 pages
5h 28m
English
| Recipe 37 | Escaping Metacharacters with the Backslash |
Suppose you have an array of quotations that uses square brackets to include words within a quote that are not part of the original quote:
| | const quotes = [ |
| | "The children [Hansel and Gretel] found a house made of candy.", |
| | "Fortune favors the bold.", |
| | "They [France] are playing against England tomorrow.", |
| | "Everything you’ve ever wanted is on the other side of fear.", |
| | // ... |
| | ] |
You want to find those instances containing square brackets so that you can add them to a new collection for search purposes:
| | const quotesWithMod = [ |
| | "The children [Hansel and Gretel] found a house made of candy.", |
| | "They [France] are playing against England tomorrow.", |
| | ] |
Since a bracket has a special ...
Read now
Unlock full access