# xarray.core.accessor_str.StringAccessor.startswith

#### StringAccessor.startswith(pat)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/accessor_str.py#L1168-L1202)

Test if the start of each string in the array matches a pattern.

The pattern pat can either be a `str` or array-like of `str`.
If array-like, it will be broadcast and applied elementwise.

* **Parameters:**
  **pat** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Character sequence. Regular expressions are not accepted.
  If array-like, it is broadcast.
* **Returns:**
  **startswith** ([array](https://numpy.org/doc/stable/glossary.html#term-array) of [`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – An array of booleans indicating whether the given pattern matches
  the start of each string element.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('9687e9fe-b2d9-4f8c-94a6-6e920577dae3','09e9159f-e90a-44e3-9f66-729de26d3141','c1dfd08e-e871-41eb-b1b1-d0de8d9e8b21','../lite/tree/../notebooks/index.html?path=5e7297fa_476c_4c12_bdf8_bfce76276978.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> da = xr.DataArray(["$100", "£23", "100"], dims="x")
>>> da
<xarray.DataArray (x: 3)> Size: 48B
array(['$100', '£23', '100'], dtype='<U4')
Dimensions without coordinates: x
>>> startswith = da.str.startswith("$")
>>> startswith
<xarray.DataArray (x: 3)> Size: 3B
array([ True, False, False])
Dimensions without coordinates: x
```

<div id="c1dfd08e-e871-41eb-b1b1-d0de8d9e8b21" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('9687e9fe-b2d9-4f8c-94a6-6e920577dae3','c1dfd08e-e871-41eb-b1b1-d0de8d9e8b21')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('9687e9fe-b2d9-4f8c-94a6-6e920577dae3','c1dfd08e-e871-41eb-b1b1-d0de8d9e8b21')">Open In Tab</button></div><div id="09e9159f-e90a-44e3-9f66-729de26d3141" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
