Browse the docs

contains

Tells whether text contains text, a list contains an item, or a record has a key.

Details #

contains(haystack, needle) takes exactly two arguments and returns true or false.

  • Text: true when the needle appears anywhere in it. Case-sensitive.

  • List: true when any item equals the needle, using the same loose equality as ==: 2 equals "2", texts compare exactly, lists and records compare deeply.

  • Record: true when the needle (as text) is one of its keys.

Parameters #

Takes 2 arguments. {{ contains(text, b) }}

Examples #

contains("Hello world", "world")
→ true
contains(tags, "urgent")
→ true
Sample variableValue
tags["home", "urgent"]
contains(nums, "2")
→ true
Sample variableValue
nums[1, 2, 3]
contains(rec, "b")
→ true
Sample variableValue
rec{"a": 1, "b": 2}

Gotchas #

  • Text matching is case-sensitive. Compare lower(a) with a lowercase needle for a case-insensitive test.