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.TrimTo remove the all leading white-space characters
our_String.TrimStartTo remove the all trailing white-space characters
our_String.TrimEndNote:
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.
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.
Step 3:
Use another “Message Box” activity and use TRIMSTART method to remove all leading white-space characters if any.
Step 4:
Use one more “Message Box” activity and use TRIMEND method to remove all trailing white-space characters if any.
Step 5:
Now, execute the project to display the appropriate results!!!
Example:
Click here to download the Source Code…
Hope it has helped you…