polars.Series.str.extract_many#

Series.str.extract_many(
patterns: Series | list[str],
*,
ascii_case_insensitive: bool = False,
overlapping: bool = False,
) Series[source]#

Use the Aho-Corasick algorithm to extract many matches.

Parameters:
patterns

String patterns to search.

ascii_case_insensitive

Enable ASCII-aware case-insensitive matching. When this option is enabled, searching will be performed without respect to case for ASCII letters (a-z and A-Z) only.

overlapping

Whether matches may overlap.

Notes

This method supports matching on string literals only, and does not support regular expression matching.

Examples

>>> s = pl.Series("values", ["discontent"])
>>> patterns = ["winter", "disco", "onte", "discontent"]
>>> s.str.extract_many(patterns, overlapping=True)
shape: (1,)
Series: 'values' [list[str]]
[
    ["disco", "onte", "discontent"]
]