I have a character vector with strings with a similar format (letters, underscore, digits):
v <- c("AB_124", "BAE_1", "LOED_1234", "H_01")
I want to add leading zeroes to have a length of 4 for the numerical part:
c("AB_0124", "BAE_0001", "LOED_1234", "H_0001")
What are ways to do it?
A
stringrsolution that supplies a function (e.g.str_pad) intostr_replace()to replace the match.