My challenge is with handling different variations in a string
var str = "2 Days, 2 Hours 10 Minutes";
When I use :
str.split(/Days/);
The result is:
["2 ", ", 2 Hours 10 Minutes"]
This method seems useful to extract values like "days", "hours" and "minutes" from a string.
However, it gets complicated when the string format changes, for example:
var str = "1 Day, 2 Hours 10 Minutes";
In this case, the string reads "1 Day" instead of "2 Days," altering the placement of "s." Is there a way to split a string based on
Day(s)
Hour(s)
Minute(s)