Skip to main content

Hi,

 

How can I format a string with leading zeros (eg. seven zeros) through the "Format" string function in text editor?

For example, in attribute creator, I want to create a new attribute which takes input id field (e.g. its value 5), and I want to return 00000005.

The screenshot below better elaborates my case.

 

image.pngAny help is highly appreciated.

Hani,

Hi @Hani Draidi​ 

 

I suggest you to use the transformer StringConcatenator:

 

String 

 

Thanks in Advance,

Danilo


Hi @Hani Draidi​ 

 

I suggest you to use the transformer StringConcatenator:

 

String 

 

Thanks in Advance,

Danilo

Thanks for the valuable input Danilo,

This works perfectly with 1-digit number, but I need a solution that formats the string based on number of zeros (Maybe this is not elaborated in my question). For example if the number is 13, the result should be 6 zeros: 00000013


I think you want to pad a string? This can be done using 

@(PadLeft,<string>,<padlenght>,<padchar>)

your example

@PadLeft(@Value(AttributeA),8,0)

As an alternative you can use the StringPadder.


I think you want to pad a string? This can be done using 

@(PadLeft,<string>,<padlenght>,<padchar>)

your example

@PadLeft(@Value(AttributeA),8,0)

As an alternative you can use the StringPadder.

Many Thanks @nielsgerrits​. It exactly does what I need!

Appreciated!


Reply