How can we help?

String contains


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}
      {$contains.found = false}
  • {
      "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 test the above example in your account by pasting the code into the edit message field and clicking the "Preview" button.

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,, 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}
  • Prudential content

In the next article, you can learn how to update contact attributes or list values.



Please sign in to leave a comment.