I should grab the one of the above values from $input then search and repalce like below:

10 min/s

1 hour

2 hours

3 day/s

4 weeks

Where i blocked is :

(\S+) mathces other than spaces i.e m,h,h/s,d,w. The conversion will be if "1 h" found then it should be converted to "1 hour" . If "2 h" then it should be converted to "2 hours". If it is "10 m" then to "10 min/s" etc. How do i make the expression conditionally here. Need help on that?