If I have these strings:
df$value[1] = "3d 4H 59M"
df$value[2] = "7d 10H 46M"
df$value[3] = "12d 2H 4M"
d = days
H = Hours
M = Minutes
As you can see, the record sometimes gives days with 2 numbers, hours with 1 number. The normal is 1 to 2 numbers in each type, D, H, M. How can I extract the values of each D, H, M in this situation?
Data
x <- c("3d 4H 59M", "7d 10H 46M", "12d 2H 4M")
([0-9]{1,2}[dDHhMm]( |$)).read.table(text = gsub('\\D', ' ', x))