I have a string
var str = "2 Days, 2 Hours 10 Minutes";
if I :
str.split(/Days/);
I get:
["2 ", ", 2 Hours 10 Minutes"]
So I think I can use string.split to split out my string and get the "days", "hours" and "minutes" with this method.
However, what do I do when I sometimes have "s" or no "s", for example:
var str = "1 Day, 2 Hours 10 Minutes";
Here my string is "1 Day" not "2 Days" so I don't have the "s" on the "day" value. Is there a way to split a string on
Day(s)
Hour(s)
Minute(s)