# xarray.core.accessor_str.StringAccessor.contains

#### StringAccessor.contains(pat, case=None, flags=0, regex=True)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/accessor_str.py#L1461-L1532)

Test if pattern or regex is contained within each string of the array.

Return boolean array based on whether a given pattern or regex is
contained within a string of the array.

The pattern pat can either be a single `str` or re.Pattern or
array-like of `str` or re.Pattern. If array-like, it is broadcast
against the array and applied elementwise.

* **Parameters:**
  * **pat** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [`re.Pattern`](https://docs.python.org/3/library/re.html#re.Pattern) or [array-like](https://numpy.org/doc/stable/glossary.html#term-array_like) of [`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [`re.Pattern`](https://docs.python.org/3/library/re.html#re.Pattern)) – Character sequence, a string containing a regular expression,
    or a compiled regular expression object. If array-like, it is broadcast.
  * **case** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *default*: [`True`](https://docs.python.org/3/builtins/constants.html#True)) – If True, case sensitive.
    Cannot be set if pat is a compiled regex.
    Equivalent to setting the re.IGNORECASE flag.
  * **flags** ([`int`](https://docs.python.org/3/builtins/functions.html#int), *default*: `0`) – Flags to pass through to the re module, e.g. re.IGNORECASE.
    see [compilation-flags](https://docs.python.org/3/howto/regex.html#compilation-flags).
    `0` means no flags. Flags can be combined with the bitwise or operator `|`.
    Cannot be set if pat is a compiled regex.
  * **regex** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *default*: [`True`](https://docs.python.org/3/builtins/constants.html#True)) – If True, assumes the pat is a regular expression.
    If False, treats the pat as a literal string.
    Cannot be set to False if pat is a compiled regex.
* **Returns:**
  **contains** ([array](https://numpy.org/doc/stable/glossary.html#term-array) of [`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – An array of boolean values indicating whether the
  given pattern is contained within the string of each element
  of the array.
