contains(text, text)

There are other functions named contains() with different numbers of arguments.
See the entire list.

contains, function

def const dash pure contains(haystack: text, needle: text): boolean

Indicates whether haystack contains needle.

Examples

haystack = "Hello World!"

show table "Contains" with
  contains(haystack, "Hello") as "Contains Hello"
  contains(haystack, "Town") as "Contains Town"

Output:

Contains Hello Contains Town
true false

Errors

Needle is an empty string.

The needle cannot be an empty text value.

Remarks

This function is case-sensitive and usable in const and dash contexts.

Recipes and best practices

If you use the result multiple times, compute it once in the pipeline and reuse it:

table Items = with
  [| as Description |]
  [| "Blue Pants" |]
  [| "red shirt" |]

Items.IsBlueCaseSensitive = contains(Items.Description, "blue")
Items.IsBlue = contains(uppercase(Items.Description), "BLUE")

show table "Blue flags" with
  Items.Description
  Items.IsBlueCaseSensitive
  Items.IsBlue

Output:

Description IsBlueCaseSensitive IsBlue
Blue Pants false true
red shirt false false

See also

User Contributed Notes
0 notes + add a note