"5 tablespoons unsalted butter, melted and cooled, 1 tablespoon, softened, for brushing muffin cups, 2 cups cornmeal"
5 tablespoons unsalted butter, melted and cooled 1 tablespoon, softened, for brushing muffin cups 2 cups cornmeal
The pattern is:
, <any number>
I did some search online and tried
.split(/(, \d+)/). But, it doesn't work as it give me five results. Can i get some help?
(, \d+)pattern is wrapped with a capturing group and that is why split method returns both matches (comma + space + 1+ digits) and non-matches (the rest).
,- a comma
\s*- 0+ whitespaces
(?=\d+\b)- followed with 1+ digits and a word boundary.
The resulting array in
resultis what you're asking for.