MCPcopy
hub / github.com/pandas-dev/pandas / fullmatch

Method fullmatch

pandas/core/strings/accessor.py:1589–1635  ·  view source on GitHub ↗

Determine if each string entirely matches a regular expression. Checks if each string in the Series or Index fully matches the specified regular expression pattern. This function is useful when the requirement is for an entire string to conform to a pattern, such as

(self, pat, case: bool = True, flags: int = 0, na=lib.no_default)

Source from the content-addressed store, hash-verified

1587
1588 @forbid_nonstring_types(["bytes"])
1589 def fullmatch(self, pat, case: bool = True, flags: int = 0, na=lib.no_default):
1590 """
1591 Determine if each string entirely matches a regular expression.
1592
1593 Checks if each string in the Series or Index fully matches the
1594 specified regular expression pattern. This function is useful when the
1595 requirement is for an entire string to conform to a pattern, such as
1596 validating formats like phone numbers or email addresses.
1597
1598 Parameters
1599 ----------
1600 pat : str
1601 Character sequence or regular expression.
1602 case : bool, default True
1603 If True, case sensitive.
1604 flags : int, default 0 (no flags)
1605 Regex module flags, e.g. re.IGNORECASE.
1606 na : scalar, optional
1607 Fill value for missing values. The default depends on dtype of the
1608 array. For the ``"str"`` dtype, ``False`` is used. For object
1609 dtype, ``numpy.nan`` is used. For the nullable ``StringDtype``,
1610 ``pandas.NA`` is used.
1611
1612 Returns
1613 -------
1614 Series/Index/array of boolean values
1615 The function returns a Series, Index, or array of boolean values,
1616 where True indicates that the entire string matches the regular
1617 expression pattern and False indicates that it does not.
1618
1619 See Also
1620 --------
1621 match : Similar, but also returns `True` when only a *prefix* of the string
1622 matches the regular expression.
1623 extract : Extract matched groups.
1624
1625 Examples
1626 --------
1627 >>> ser = pd.Series(["cat", "duck", "dove"])
1628 >>> ser.str.fullmatch(r"d.+")
1629 0 False
1630 1 True
1631 2 True
1632 dtype: bool
1633 """
1634 result = self._data.array._str_fullmatch(pat, case=case, flags=flags, na=na)
1635 return self._wrap_result(result, fill_value=na, returns_string=False)
1636
1637 @forbid_nonstring_types(["bytes"])
1638 def replace(

Callers 12

time_fullmatchMethod · 0.80
_str_fullmatchMethod · 0.80
test_fullmatchFunction · 0.80
test_fullmatch_na_kwargFunction · 0.80
test_flags_kwargFunction · 0.80
test_str_fullmatchFunction · 0.80

Calls 2

_wrap_resultMethod · 0.95
_str_fullmatchMethod · 0.45

Tested by 10

test_fullmatchFunction · 0.64
test_fullmatch_na_kwargFunction · 0.64
test_flags_kwargFunction · 0.64
test_str_fullmatchFunction · 0.64