December 2023
Intermediate to advanced
242 pages
5h 28m
English
| Recipe 4 | Extracting Lists from Text with slice() |
Suppose you run an online shop selling thousands of different clothes. You’re tasked with making the products searchable by color. The problem is the available colors for each product are listed as a sentence in the product description. You need a way to find and extract those colors programmatically to build a searchable database.
So if you have a product description like this:
| | Feel confident in even the most unforeseen weather conditions with these |
| | waterproof trail-running shoes helping you stay dry. Available in four new |
| | colors: Velvet Brown, Black, Golden Moss, Medium Blue. |
You want to extract the colors and store them in an array like this:
| | ["Velvet Brown", "Black", "Golden Moss" ... |
Read now
Unlock full access