MCPcopy
hub / github.com/pydata/xarray / match

Method match

xarray/core/accessor_str.py:1523–1558  ·  view source on GitHub ↗

Determine if each string in the array matches a regular expression. 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. Paramete

(
        self,
        pat: str | bytes | Pattern | Any,
        case: bool | None = None,
        flags: int = 0,
    )

Source from the content-addressed store, hash-verified

1521 return self._apply(func=func, func_args=(pat,), dtype=bool)
1522
1523 def match(
1524 self,
1525 pat: str | bytes | Pattern | Any,
1526 case: bool | None = None,
1527 flags: int = 0,
1528 ) -> T_DataArray:
1529 """
1530 Determine if each string in the array matches a regular expression.
1531
1532 The pattern `pat` can either be a single ``str`` or `re.Pattern` or
1533 array-like of ``str`` or `re.Pattern`. If array-like, it is broadcast
1534 against the array and applied elementwise.
1535
1536 Parameters
1537 ----------
1538 pat : str or re.Pattern or array-like of str or re.Pattern
1539 A string containing a regular expression or
1540 a compiled regular expression object. If array-like, it is broadcast.
1541 case : bool, default: True
1542 If True, case sensitive.
1543 Cannot be set if `pat` is a compiled regex.
1544 Equivalent to setting the `re.IGNORECASE` flag.
1545 flags : int, default: 0
1546 Flags to pass through to the re module, e.g. `re.IGNORECASE`.
1547 see `compilation-flags <https://docs.python.org/3/howto/regex.html#compilation-flags>`_.
1548 ``0`` means no flags. Flags can be combined with the bitwise or operator ``|``.
1549 Cannot be set if `pat` is a compiled regex.
1550
1551 Returns
1552 -------
1553 matched : array of bool
1554 """
1555 pat = self._re_compile(pat=pat, flags=flags, case=case)
1556
1557 func = lambda x, ipat: bool(ipat.match(x))
1558 return self._apply(func=func, func_args=(pat,), dtype=bool)
1559
1560 def strip(
1561 self, to_strip: str | bytes | Any = None, side: str = "both"

Callers

nothing calls this directly

Calls 2

_re_compileMethod · 0.95
_applyMethod · 0.95

Tested by

no test coverage detected