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.
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')
Contains string
A simple example of a Power Automate Contains string expression.
contains(variables('text'),'Skywalker')
=> true (if text = "Luke Skywalker")
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
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