Insert zeros beginning of string

Hello friends,
@rkelchuri, @Ninett_Panfir, @Rammohan91, @balupad14, @Florent_Salendres, @vvaidya, @Palaniyappan, @ClaytonM, @vvaidya, @lakshman, @Dave,

I need to check if a string has 11 digits.
In case it has not 11 digits I need to insert at the beginning of the string as many zeros as to complete the string for having 11 digits.
Examples: 555110988 β†’ 00555110988
5110988 β†’ 00005110988
Thank you so much,

Cami

1 Like

Fine
this expression would help you in a assign activity
yourstringvariable = yourstringvariable.padleft(11,CChar(β€œ0”))

Cheers @CamiCat

3 Likes

Hi @CamiCat - you can achieve this by changing the format when outputting your number as a string. So it would be YourNumber.ToString(β€œ00000000000”).

If it is already a string variable I would convert it to a number first, then output to a string as as shown above. I would recommend converting to a number if it isn’t one already as that will be your input validation step.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.