I'm working on breaking down a string to:
- Remove the initial word "lunch"
- Separate the days of the week from their corresponding food items
The input is received as a string in this format:
var s = 'lunch monday: chicken and waffles, tuesday: mac and cheese, wednesday: salad';
My objective is to split it into:
[monday, chicken and waffles, tuesday, mac and cheese, wednesday, salad]
I'm currently using
s = s.split(' ').splice(1, s.length-1).join(' ').split(':');
With this process, I get:
["monday", " chicken and waffles, tuesday", " mac and cheese, wednesday", " salad"]
However, it only splits at the :
, leaving the ,
intact. I attempted using regex split(":|\\,");
to split based on either :
or ,
, but that didn't work.
Any suggestions?