Skip to content

contains

strings · scripts/strings/contains.m

: retval = contains (str, pattern)
: retval = contains (str, pattern, "IgnoreCase", ignore_case)

Check whether string(s) contain pattern(s).

contains returns a logical array the same size as str indicating which strings contain at least one of the patterns in pattern. The comparison respects letter case unless the option "IgnoreCase" is set to true.

contains ("hello world", "world")
  ⇒ 1
contains ({"hello", "world"}, "lo")
  ⇒ [1, 0]
contains ({"Abc", "XyZ"}, {"ab", "yz"}, "IgnoreCase", true)
  ⇒ [1, 1]