Solved

Padding Text to a fixed length

  • 1 December 2023
  • 2 replies
  • 101 views

Userlevel 2
Badge +6
  • Automate the Universe SME
  • 7 replies

Is there a way to pad text in order to make it a fixed length? For instance, I have a string of numbers that can be anywhere from one to five characters. If the string only has one character, I would like to add four zeros to the left of the string for a total length of five characters.  I'm new to this platform so any assistance is greatly appreciated. 

icon

Best answer by arjun.meda 4 December 2023, 09:41

View original

2 replies

Userlevel 5
Badge +9

Yes, absolutely. Here are the steps to pad text to make it to a fixed length.

  1. Get the length of the string using the action: String → Length
  2. Loop while the length of the string is less than 5.
  3. Add 0 to your string using the action String → Assign
  4. Get the length of the string again (within the loop) to check if it has reached 5 in the next iteration.

Attached a sample automation for your reference.

Hope this helps, let me know.

Userlevel 2
Badge +6

Thank you very much Arjun! I was hoping there might be an action for this. I appreciate your help.

Reply