The strContains utility can be used to find a string of characters within another string of characters.
Our example uses the utility to check if fire exists in firestorm, and then prints the result with an {if}
statement.
- Used in:
Message Automations
Data Automations
- Syntax:
{$utils->strContains($lookup_str*, $string*, $caseSensitive)}
{$contains.lookup_str = 'Fire'} {$contains.string = 'firestorm'} {$contains.caseSensitive = true} {if $utils->strContains($contains.lookup_str, $contains.string, $contains.caseSensitive)} {$contains.found = true} {else} {$contains.found = false} {/if} {$utils->jsonPrettyPrint($contains)}
{ "lookup_str": "Fire", "caseSensitive": true, "found": false }
Parameter | Description | Required | Expected | Default |
---|---|---|---|---|
lookup_str | String of characters to be searched for. | required | String | NA |
string | Given string to be checked for the specified lookup_str. | required | String | NA |
caseSensitive | Determines if the search should adhere to letter casing (true or false). | optional | Boolean string | true |
You can use this utility to check whether a contact's attribute contains a certain string. This is useful if you have data that is non-normalized.
For example, if you have a contact attribute of "company name" with non-normalized values such as: Prudential Reality, Prudential Inc, prudential, Prudential.com, you can use the string contains utility to find if company name contains the word "Prudential" and then render content in a message based on the result.
{$prudential = $utils->strContains('prudential',{$contact.companyname}, false)}
{if $prudential}Prudential content{/if}
In the next article learn how to update contact attributes or list values.
Comments
0 comments
Please sign in to leave a comment.