Skip to content

Commit dddebff

Browse files
Enhance documentation for StringMethods.fullmatch with examples and usage of regex flags
1 parent 75de765 commit dddebff

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pandas/core/strings/accessor.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,34 @@ def fullmatch(self, pat, case: bool = True, flags: int = 0, na=lib.no_default):
14691469
containing alternation (|). For regex patterns with alternation operators,
14701470
the method ensures proper grouping by wrapping the pattern in parentheses
14711471
when using PyArrow-backed string arrays.
1472+
1473+
Examples
1474+
--------
1475+
>>> import pandas as pd
1476+
>>> s = pd.Series(["foo", "bar", "foobar", ""])
1477+
>>> s.str.fullmatch("foo")
1478+
0 True
1479+
1 False
1480+
2 False
1481+
3 False
1482+
dtype: bool
1483+
1484+
>>> s.str.fullmatch(".*")
1485+
0 True
1486+
1 True
1487+
2 True
1488+
3 True
1489+
dtype: bool
1490+
1491+
Using regular expressions with flags:
1492+
1493+
>>> import re
1494+
>>> s = pd.Series(["FOO", "foo", "FoO"])
1495+
>>> s.str.fullmatch("foo", flags=re.IGNORECASE)
1496+
0 True
1497+
1 True
1498+
2 True
1499+
dtype: bool
14721500
"""
14731501
is_pyarrow = False
14741502
arr = self._data.array

0 commit comments

Comments
 (0)