Per title, I am looking for a way to remove the leading zero from both sides of the hyphen.
codes <- c("0002-01014", "0020-0014","00014-00010")
want <- c("2-1014","20-14","14-10")
I suppose one can split the numbers into two, remove leading zero, then paste together, but I was wondering if there is more refined method using single step of str_extract(), str_replace(), or similars.
Edit:
I am currently using
str_split("0002-01010","-",simplify=T) %>%
str_replace("^0+(?!$)", "") %>%
str_c(collapse="-")
and was curious if there is an alternative method that can be achieved in single line.