I'm very new to regular expressions and I'm have some trouble putting them together at the moment. I'm working with R at the moment, and I'm looking to ensure all strings in a character vector are of length 3.
So say I have a character vector of the following:
['1','23','113']
What regular expression would I be able to use to ensure that the length of each string is 3
and in the cases where it is less, add 0's to the start?
So the output I would be looking for would be:
['001','023','113']
An explanation alongside the answer would be really appreciated, thanks.
Edit: The length of strings in the character vector will be greater than or equal to 1 and less than or equal to 3.