containsAny

containsAny, function

def pure containsAny(haystack: text, needles: text, separator: text): boolean

Indicates whether haystack contains any needle, as obtained by splitting needles through separator.

Examples

haystack = "1+2+3+4"
needles = "-,+,*,/"
separator = ","

show table "Contains any" with
  containsAny(haystack, needles, separator)

Output:

containsAny(haystack, needles, separator)
true

Remarks

The separator cannot be an empty text value. This function is case-sensitive and sensitive to spaces around separator.

Recipes and best practices

Use containsAny to filter entries that include any forbidden tokens:

table Items = with
  [| as Name |]
  [| "KEEP" |]
  [| "TODELETE" |]
  [| "deprecated" |]

ToRemove = "TODELETE,deprecated"
keep where not containsAny(Items.Name, ToRemove, ",")

show table "Remaining" with Items.Name

Output:

Name
KEEP

When inputs have inconsistent casing, normalize before calling containsAny:

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

Items.IsBlueCaseSensitive = containsAny(Items.Description, "blue,red,green", ",")
Items.IsBlue = containsAny(uppercase(Items.Description), "BLUE,RED,GREEN", ",")

show table "Colors" with
  Items.Description
  Items.IsBlueCaseSensitive
  Items.IsBlue

Output:

Description IsBlueCaseSensitive IsBlue
Blue Pants false true
red shirt true true

See also

User Contributed Notes
0 notes + add a note