polars.internals.series.StringNameSpace.extract_all

StringNameSpace.extract_all(pattern: str) polars.internals.series.Series

Extract each successive non-overlapping regex match in an individual string as an array

Parameters
pattern

A valid regex pattern

Returns
List[Utf8] array. Contain null if original value is null or regex capture nothing.

Examples

>>> s = pl.Series("foo", ["123 bla 45 asd", "xyz 678 910t"])
>>> s.str.extract_all(r"(\d+)")
shape: (2, 1)
┌────────────────┐
│ extracted_nrs  │
│ ---            │
│ list[str]      │
╞════════════════╡
│ ["123", "45"]  │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ ["678", "910"] │
└────────────────┘