str.
match
Determine if each string matches a regular expression.
Analogous to contains(), but more strict, relying on re.match() instead of re.search().
contains()
re.match()
re.search()
Character sequence or regular expression.
If True, case sensitive.
Flags to pass through to the re module, e.g. re.IGNORECASE.
Fill value for missing values.
A Series of boolean values indicating whether the given pattern can be matched in the string of each element of the Series.
Examples
>>> s = ps.Series(['Mouse', 'dog', 'house and parrot', '23', np.NaN]) >>> s.str.match('dog') 0 False 1 True 2 False 3 False 4 None dtype: object
>>> s.str.match('mouse|dog', case=False) 0 True 1 True 2 False 3 False 4 None dtype: object
>>> s.str.match('.+and.+', na=True) 0 False 1 False 2 True 3 False 4 True dtype: bool
>>> import re >>> s.str.match('MOUSE', flags=re.IGNORECASE) 0 True 1 False 2 False 3 False 4 None dtype: object