I have a list of string like so:
batch1, batch2, batch3, batch10, batch11
I am trying to add a 0 before the single digits batch01, batch02, batch03, batch10, batch11
I have found many similar questions and tried to write my own regex. I am very close, but I can't quite make it do what I want.
Batch <- gsub('(.{5})([0-9]{1}\\b)','\\10\\2', Batch)
outputs batch01, batch02, batch 03, batch100, batch110
\\s instead of \\b doesn't change any values
sampleNames$Batch <- gsub('(.{5})([0-9]{1})','\\10\\2', sampleNames$Batch) outputs bacth01, batch02, batch03, batch010, batch011
I've played around with a few other versions but I cannot seem to get it correct. I know this is a somewhat repetitive question, but I have not been able to alter previous solutions to do what I need to do.