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
==:2equals"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")→
truecontains(tags, "urgent")→
true| Sample variable | Value |
|---|---|
tags | ["home", "urgent"] |
contains(nums, "2")→
true| Sample variable | Value |
|---|---|
nums | [1, 2, 3] |
contains(rec, "b")→
true| Sample variable | Value |
|---|---|
rec | {"a": 1, "b": 2} |
Gotchas #
Text matching is case-sensitive. Compare
lower(a)with a lowercase needle for a case-insensitive test.