December 2023
Intermediate to advanced
242 pages
5h 28m
English
| Recipe 65 | Extracting Text Enclosed in Single Quotes |
Suppose the data source for your mini-game widget lists the nicknames in single quotes rather than double quotes. Extracting the text within single quotes can be more challenging compared to double quotes because the nickname itself could contain an apostrophe.
For example:
| | Michael Eugene Archer, also known as 'D'Angelo' |
You need a solution that can accurately identify a pair of single quotation marks while distinguishing them from an apostrophe.
Take advantage of lookarounds:
| | const str = |
| | `1. Michael Eugene Archer, also known as 'D'Angelo' |
| | 2. Scarlett Johansson, also known as 'Scarjo' |
| | 3. Bradley Cooper, ... |
Read now
Unlock full access