About this article
Contains() is a condition that returns True/False dependent on a SourceValue containing a SearchValue. Contains() is case sensitive and comparisons between a SourceValue and SearchValue that are case variable can be compared using a Lower() or Upper() function to ensure the values are of the same case.
Pre-requisites
|
Syntax
Syntax | {{Contains(SourceValue, SearchValue)}} |
Output | True/False |
Example 1
Using the Contains() function to check if a sentence contains a word.
Binding | {{Contains("This is a longer sentence with some random text", "random")}} |
Output | True |
Example 2
Using the Contains() function to check if a sentence contains a word that doesn't match with the case in the SourceValue. Notice the capital R in the SearchValue.
Binding | {{Contains("This is a longer sentence with some random text", "Random")}} |
Output | False |
Example 3
Using the Contains() function with a Lower() function to match the case and make a comparison.
Binding | {{Contains(Lower("This is a longer sentence with some random text"), Lower("Random"))}} |
Output | True |
Example 4
Using the Not() condition with a Lower() function for checking if a piece of text doesn't contain a word.
Binding | {{Not(Contains(Lower("This is a longer sentence with some random text"), Lower("Random")))}} |
Output | False |
Example 5
Using the IfElse() function to see if Form.Body contains legal text, if it does then make a note at the binding in the bottom.
Binding | {{IfElse(Contains(Lower(Form.Body), "legal"), "There is legal text in the above document. Ensure it's legally compliant.", "")}} |
Input | Form.Body = "This is legal text." |
Condition | True |
Output | "There is legal text in the above document. Ensure it's legally compliant." |
Example 6
Using the IfElse() function to see if Form.Subject matches any of the compare values.
If it does then show the text "Match found", else show "No match found".
Binding | {{IfElse(Contains("large cat, small cat, dog", Form.Subject), "Match found", "No match found")}} | |||||
Input | cat | Cat | large cat | small cat | dog | fox |
Output | "Match found" | "No match found" | "Match found" | "Match found" | "Match found" | "No match found" |
You can add the Concat() function to see if Form.Subject exactly matches any of the compare values.
If it does then show the text "Match found", else show "No match found".
Binding | {{IfElse(Contains("##large cat##, ##small cat##, ##dog##",Concat("##",Concat(Form.Subject,"##"))), "Match found", "No match found")}} | |||||
Input | cat | Cat | large cat | small cat | dog | fox |
Output | "No match found" | "No match found" | "Match found" | "Match found" | "Match found" | "No match found" |
|
Example 7
Using the IfElse() function to see if Form.Subject matches any of the compare values.
If it does then show the text (VisibilityType.Visible), else hide the text (VisibilityType.Hidden).
Binding | {{IfElse(Contains("large cat, small cat, dog", Form.Subject), VisibilityType.Visible, VisibilityType.Hidden)}} | |||||
Input | cat | Cat | large cat | small cat | dog | fox |
Output | Visible | Hidden | Visible | Visible | Visible | Hidden |
You can add the Concat() function to see if Form.Subject exactly matches any of the compare values.
If it does then show the text (VisibilityType.Visible), else hide the text (VisibilityType.Hidden).
Binding | {{IfElse(Contains("##large cat##, ##small cat##, ##dog##",Concat("##",Concat(Form.Subject,"##"))), VisibilityType.Visible, VisibilityType.Hidden)}} | |||||
Input | cat | Cat | large cat | small cat | dog | fox |
Output | Hidden | Hidden | Visible | Visible | Visible | Hidden |
|
Comments
0 comments
Article is closed for comments.