The Power Automate contains function can be used with strings or arrays. As the name implies, you can check, if a string contains a string or an array contains an element.
Note: Power Automate Conditions also offer contains, which may be more suitable for your use case.
![The Power Automate Contains Function Guide 3 Power Automate Condtion contains](https://zeitgeistcode.com/wp-content/uploads/2022/08/Power-Automate-Condtion-contains-1024x279.png)
Power Automate Contains Function
The Power Automate Contains function checks, if a contains b. It works for strings, where a and b are strings and it works for arrays, where a is an array and b is a potential array element.
Note: The Contains function is case-sensitive. For a case-insensitive contains expression, scroll down to the examples.
Syntax
contains(collection: array|string, value: string)
Input parameters
- collection (mandatory): The array or string that might contain an element or string defined in value parameter.
- value (mandatory): The array element or string that should be contained in the given array/string,
Return value
- true, if array/string contain the element/string.
- false, if array/string not contain the element/string.
Power Automate contains expression examples
Here are some examples of Power Automate contains expressions.
Contains array
A simple example of a Power Automate Contains array expression.
contains(variables('myArray'),'banana')
![The Power Automate Contains Function Guide 4 Power Automate contains array](https://zeitgeistcode.com/wp-content/uploads/2022/08/Power-Automate-contains-array-1024x598.png)
Contains string
A simple example of a Power Automate Contains string expression.
contains(variables('text'),'Skywalker')
=> true (if text = "Luke Skywalker")
![The Power Automate Contains Function Guide 5 Power Automate Contains Function Example](https://zeitgeistcode.com/wp-content/uploads/2022/08/Power-Automate-Contains-Function-Example-1024x580.png)
Contains line break
In case you need to check, if a string contains a line break. Use: decodeUriComponent(‘%0A’)
contains(variables('text'),decodeUriComponent('%0A'))
=> true
![The Power Automate Contains Function Guide 6 Power Automate contains line break](https://zeitgeistcode.com/wp-content/uploads/2022/08/Power-Automate-contains-line-break-1024x607.png)
Case-insensitive contains expression
Per default Power Automate contains is case-sensitive. You can trick this behavior by switching the case for both parameters by using toLower function.
contains(toLower(variables('text')),'skywalker')
=> true
![The Power Automate Contains Function Guide 7 Power Automate Contains Case insensitive expression](https://zeitgeistcode.com/wp-content/uploads/2022/08/Power-Automate-Contains-Case-insensitive-expression-1024x563.png)