# xarray.DataArray.str.findall

#### DataArray.str.findall(pat, case=None, flags=0)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/accessor_str.py#L2282-L2373)

Find all occurrences of pattern or regular expression in the DataArray.

Equivalent to applying re.findall() to all the elements in the DataArray.
Results in an object array of lists.
If there is only one capture group, the lists will be a sequence of matches.
If there are multiple capture groups, the lists will be a sequence of lists,
each of which contains a sequence of matches.

If pat is 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)) – 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.
* **Returns:**
  **extracted** (`object array`)
* **Raises:**
  * [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – pat has no capture groups.
  * [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – case is set when pat is a compiled regular expression.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('43395744-76d8-4d16-938b-0be5e3f13f88','00d162f0-1096-43de-9b37-4fffd8bb247f','be5c6511-d88f-44c3-8e98-88b657c1effd','../lite/tree/../notebooks/index.html?path=918dc08f_c854_4ca6_8a29_fd3ddc932603.ipynb','None')">Try it in your browser!</button></div>

Create a string array

```pycon
>>> value = xr.DataArray(
...     [
...         [
...             "a_Xy_0",
...             "ab_xY_10-bab_Xy_110-baab_Xy_1100",
...             "abc_Xy_01-cbc_Xy_2210",
...         ],
...         [
...             "abcd_Xy_-dcd_Xy_33210-dccd_Xy_332210",
...             "",
...             "abcdef_Xy_101-fef_Xy_5543210",
...         ],
...     ],
...     dims=["X", "Y"],
... )
```

Extract matches

```pycon
>>> value.str.findall(r"(\w+)_Xy_(\d*)")
<xarray.DataArray (X: 2, Y: 3)> Size: 48B
array([[list([('a', '0')]), list([('bab', '110'), ('baab', '1100')]),
        list([('abc', '01'), ('cbc', '2210')])],
       [list([('abcd', ''), ('dcd', '33210'), ('dccd', '332210')]),
        list([]), list([('abcdef', '101'), ('fef', '5543210')])]],
      dtype=object)
Dimensions without coordinates: X, Y
```

<div id="be5c6511-d88f-44c3-8e98-88b657c1effd" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('43395744-76d8-4d16-938b-0be5e3f13f88','be5c6511-d88f-44c3-8e98-88b657c1effd')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('43395744-76d8-4d16-938b-0be5e3f13f88','be5c6511-d88f-44c3-8e98-88b657c1effd')">Open In Tab</button></div><div id="00d162f0-1096-43de-9b37-4fffd8bb247f" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>

#### SEE ALSO
[`DataArray.str.extract`](xarray.DataArray.str.extract.html.md#xarray.DataArray.str.extract), [`DataArray.str.extractall`](xarray.DataArray.str.extractall.html.md#xarray.DataArray.str.extractall), [`re.compile`](https://docs.python.org/3/library/re.html#re.compile), [`re.findall`](https://docs.python.org/3/library/re.html#re.findall), [`pandas.Series.str.findall`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.findall.html#pandas.Series.str.findall)
