Exploratory Community

How to add 0 padding to number inside text

#1

Support you have text like below and you want to add 0 padding to the second numeric component if it is a one-digit number.

image

For example, 1997-1-10 needs to be updated as 2021-01-10 and 2021-4-30 needs to be updated as 2021-04-30 and you want to keep 2010-10-10 as is.

To do so, you can use the Work with Text Data column menu. Select Replace then select Text.

And select “Regular Expression” radion button then type in the below parameters.

From: (\d{4})-(\d{1})-(\d{2})
To: \1-0\2-\3

And this will add 0 padding to the left if needed.

1 Like