Checking for items in a string

Ive been trying to tidy up some of my automations and am struggling with the syntax on this one. What Im trying to achieve is check if a string contains one or more of a list of items. Heres an example…

{{ (‘Kia’ or ‘Ford’) in “There are two cars. One is a Vauxhall, the other is a Ford” }}

Whilst this is grammatically accepted, it returns false. Reversing the order to Ford or Kia returns true.

Any suggestions on a better option for this?

{{ 'There are two cars. One is a Vauxhall, the other is a Ford.' is search('(Kia|Ford)') }}
  • search accepts a regex pattern.
  • The pattern '(Kia|Ford)' matches the strings Kia or Ford.
1 Like

Perfect, thank you!

1 Like