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

To test the above example in your account, paste the code into your message HTML or Sculpt Block and click the Preview button.

Use case

You can use the strContains 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 companyname with non-normalized values such as: Threads Clothing, Threads Inc, threads,, you can use the string contains utility to find if company name contains the word threads and then render content in a message based on the result.

  • {$threads = $utils->strContains('threads',{$contact.companyname}, false)}
    {if $threads}Threads content{/if}
  • Threads content

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



Please sign in to leave a comment.