Knowing how to use strings is essential in every programming environment. Power Automate strings are no exception to this. Unfortunately, working with String within Power Automate is a little more complicated than in most programming languages. In most cases we need to use Power Automate expressions, which are not always that intuitive. With this article I try to demonstrate solutions for common use cases. Since I’m learning myself, please feel free to let me know, if there is a better solution.
12 Power Automate String Manipulation Examples
There is a set of operations you need to know to successfully work with strings. You need to know how to concatenate strings, join strings, split strings, convert strings and more. The following examples will show you how to solve these tasks with Power Automate.
Let’s get to know Power Automate string functions to solve common problems.
When you want to append on string to another, you can use the Concat function like shown below:
Converting an array of strings into one string by appending all items with seperator can be achieved with the Join function. In the example below a ‘,’ is used to separate the items in the resulting string.
Split string by delimiter
Having something like CSV line where different string values a separated by commas is common. Often you want to transfer the values into an array for further processing. To convert the line to an array you can use the Power Automate split string function like shown in the example below.
Replace multiple strings
When you have a text and want to replace multiple strings with one string. For instance you want to replace orange, apple and banana with fruits like this:
I like orange, apple and banana. => I like fruits, fruits and fruits.
You can do this with nested replace functions:
But this gets quickly hard to maintain with a large number of replace calls. Here is a way to replace the items in a loop.
This will be the function to replace the strings:
This is the flow to replace the strings.
Append string new line break
For Power Automate strings there is no standard way of integrating line breaks. In many other programming languages it is common to use ‘\n’ which is not working for Power Automate. You simulate this solution in the following way.
Remove characters from a string
To remove characters from a string in Power Automate you can simply replace them by an empty string.
To remove multiple characters in one Power Automate expression you can nest multiple replace function calls.
In the example below we remove the brackets of the string “(100)”:
String begins with
Want to check if a string begins with a certain string? Use the startsWith function:
String ends with
Want to check if a string ends with a certain string? Use the endsWith function:
TO find out if one strings contains the other, use the Contains function as shown.
Get string length
Getting a Power Automate string’s size can be achieved with the Length function.
See the Power Automate length of string example below:
String remove last character
To remove the last character of a string, you need three functions:
- Substring to define the new string
- Length to get the number of characters your string has
- Sub to subtract the one character from the string length to provide substring which is the last character
String to number
When you need to convert a Power Automate string to integer, you can use the int function.
|This is how Power Automate converts a string to an integer:|
int('010') // Power Automate convert string to integer