Skip to main content
Solved

Padding Text to a fixed length


Forum|alt.badge.img+9
  • Cadet | Tier 2
  • 8 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. 

Best answer by arjun.meda

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.

View original
Did this topic help answer your question?

2 replies

arjun.meda
Automation Anywhere Team
Forum|alt.badge.img+12
  • Automation Anywhere Team
  • 47 replies
  • Answer
  • December 4, 2023

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.


Forum|alt.badge.img+9
  • Author
  • Cadet | Tier 2
  • 8 replies
  • December 4, 2023

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings