contains function. String.(Power Automate Cloud flows)

02/22/2024

Japanese version.

This function checks whether the specified text is included.

It has a similar role to indexOf, with the following differences.

FunctionResultCase-sensitive.
containsBoolean.
Exists (true).
Does not exist (false).
Case-sensitive.
indexOfStart position of the found text.Not Case-sensitive.

contains also has a separate function of the same name that checks for the presence of a specified item in an array.

Spec

contains('<text>', '<value>')
ArgumentDefaultDescription
textRequired fieldTarget text.
valueRequired fieldText to be searched.

How to use

Often used in "Condition".

It is also frequently used to initialize or set variables of type "Boolean" in order to use the result in subsequent actions.

Clicking on contains in the "Expression" tab sets the function name and () in the formula field.

If you see something like the following, your settings are complete.

You can change the contents of the function by clicking on the purple icon.

For example, if contains('abcdef','cd') is specified, the result is true because "cd" is contained in "abcdef".

When dynamic content or variables are used in expressions, special specifications are required.

(How to get dynamic content with expressions.)

contains is case-sensitive, so contains('abcDef','Cd') will result in false.

To incorporate the result of this function into a "Condition" action, set the following.

LeftThe result of the contains function.
Centeris equal to
Righttrue

"If yes" is the action when the specified text exists, and "If no" is the action when the specified text does not exist.

---

Links

String Functions