You would input like 1d5h40m and it would output 1 day, 5 hours and 40 minutes - Any ways to do that?
Split the input string with non digits and extract what you need from that splitted string. This will only work if input is in the exact pattern you mentioned.
let str = '1d5h40m';
let time = str.split(/\D/);
console.log(time[0] + 'day', time[1] + 'hour', time[2] + 'minute');
How about this? Although you would have to do more work to figure out the plurality of day(s), hour(s) and minute(s).
const duration = '1d5h40m';
var formatted = duration
.replace('d', ' day, ')
.replace('h', ' hours and ')
.replace('m', ' minutes ');
console.log(formatted);
Its lengthy but working
var time="1d5h40m";
const day = time.split("d")[0];
time = time.replace(day+"d", "");
const hours = time.split("h")[0];
time = time.replace(hours+"h", "");
const minutes = time.split("m")[0];
console.log(day+" day, "+hours+" hours and,"+minutes+" minutes");