How To Trim/Clean The String – In UiPath

There is always a possibility of extra spaces being added to the text by mistake, which needs to be handled before performing any operations on the data.

TRIM() method of string can be used and it removes all leading and trailing white-space characters from the current String.

Let us see how to use it!!!

To remove the all leading and trailing white-space characters
our_String.Trim

To remove the all leading white-space characters
our_String.TrimStart

To remove the all trailing white-space characters
our_String.TrimEnd

Note:
Replace user_String with your string value

Example

Implementation using UiPath :

Let us implement a workflow which takes input from the user and displays the text by removing the extra spaces in it as per the method used.

Step 1:
Drag “Input Dialog” activity into the designer panel and try to capture the user input into a variable.

UiPath trim a string 1.PNG

Step 2:
Drag “Message Box” activity into the designer panel and use TRIM method to remove all leading and trailing white-space characters if any.

UiPath trim a string 2

Step 3:
Use another “Message Box” activity and use TRIMSTART method to remove all leading white-space characters if any.

UiPath trim a string 3

Step 4:
Use one more “Message Box” activity and use TRIMEND method to remove all trailing white-space characters if any.

UiPath trim a string 4.PNG

Step 5:
Now, execute the project to display the appropriate results!!!

Example:
UiPath trim a string 5.PNG

Click here to download the Source Code…

Hope it has helped you… 

Advertisements

Author: Sharath Raju

Founder@www.ExcelCult.com

Leave a Reply