Remove leading and trailing spaces from a string
In Power Automate Desktop, you can usually find an action that does what you want and simply drag and drop it, but when you extract data from a website or on-premises software, you may get unnecessary data along with it.
This article explains how to remove leading and trailing spaces from the text data you get.
Implement by copying and pasting
Section titled “Implement by copying and pasting”Copy the following code and paste it into the Power Automate Desktop flow designer to add the action.
Text.Trim Text: $'''%' ←full-width space half-width spaces→ '%''' TrimOption: Text.TrimOption.Both TrimmedText=> TrimmedTextImplement in Power Automate Desktop
Section titled “Implement in Power Automate Desktop”-
In “Search actions”, type “Trim text” and set the parameters as follows.
Parameter Value Text to trim The target variable, or a string enclosed in %‘’% What to trim Choose the beginning only, the end only, or both -
When you run the flow, the action returns the string with whitespace characters (spaces, tabs, line breaks, and so on) removed from the beginning and end of the target text. Whitespace in the middle of the string isn’t removed.