About EasyMorph Tutorials & Examples Web-help

Adding leading zeros to numbers


Hi there,

I have a column with numbers from 129 to 8712.
I would like to add leading zeros, 129 --> 0129, so that all numbers have 4 digits.

I can do it with RegEx in a Textfile, Search:^(\d{3})\t —> ‘\t’ because I use tabstops to separte colums in the textfile
Replace: 0\1

But in the RegEx-Transformation in EasyMorph I can only search but not replace with RegEx. I’m not that good with the functions in EM, maybe there is a way to perform this task?



Hi Nima,

You can do it with Modify column transformation and the following expression:

padstart([Column name], '0', 4)

Here is an example project: PadNumbers.morph (1.2 KB)




Hi Andrew,

thank you very much ! Works perfectly! I knew there must be an function that I don’t know about.




You are welcome!