cudf.core.accessors.string.StringMethods.match#

StringMethods.match(pat: str, case: bool = True, flags: int = 0, na=<no_default>) Series | Index[source]#

Determine if each string matches a regular expression.

Parameters:
patstr or compiled regex

Character sequence or regular expression.

flagsint, default 0 (no flags)

Flags to pass through to the regex engine (e.g. re.MULTILINE)

nascalar, optional

Fill value for missing values. The default depends on dtype of the array. For the "str" dtype, False is used. For object dtype, numpy.nan is used. For the nullable StringDtype, pandas.NA is used.

Returns:
Series or Index of boolean values.

Examples

>>> import cudf
>>> s = cudf.Series(["rapids", "ai", "cudf"])

Checking for strings starting with a.

>>> s.str.match('a')
0    False
1     True
2    False
dtype: bool

Checking for strings starting with any of a or c.

>>> s.str.match('[ac]')
0    False
1     True
2     True
dtype: bool

Pandas Compatibility Note

pandas.Series.str.match()

Parameter case is currently not supported. The flags parameter currently only supports re.DOTALL, re.MULTILINE and re.IGNORECASE.