class_docstr: Namespace for string related expressions.
class_docstr_tok: ["Namespace","for","string","related","expressions","."]
docstr: Count all successive non-overlapping regex matches.
  
  Parameters
  ----------
  pattern
      A valid regular expression pattern, compatible with the `regex crate
      <https://docs.rs/regex/latest/regex/>`_.
  literal
      Treat `pattern` as a literal string, not as a regular expression.
  
  Returns
  -------
  Expr
      Expression of data type :class:`UInt32`. Returns null if the
      original value is null.
  
  Examples
  --------
  >>> df = pl.DataFrame({"foo": ["123 bla 45 asd", "xyz 678 910t", "bar", None]})
  >>> df.with_columns(
  ...     pl.col("foo").str.count_matches(r"\d").alias("count_digits"),
  ... )
  shape: (4, 2)
  ┌────────────────┬──────────────┐
  │ foo            ┆ count_digits │
  │ ---            ┆ ---          │
  │ str            ┆ u32          │
  ╞════════════════╪══════════════╡
  │ 123 bla 45 asd ┆ 5            │
  │ xyz 678 910t   ┆ 6            │
  │ bar            ┆ 0            │
  │ null           ┆ null         │
  └────────────────┴──────────────┘
  
  >>> df = pl.DataFrame({"bar": ["12 dbc 3xy", "cat\\w", "1zy3\\d\\d", None]})
  >>> df.with_columns(
  ...     pl.col("bar")
  ...     .str.count_matches(r"\d", literal=True)
  ...     .alias("count_digits"),
  ... )
  shape: (4, 2)
  ┌────────────┬──────────────┐
  │ bar        ┆ count_digits │
  │ ---        ┆ ---          │
  │ str        ┆ u32          │
  ╞════════════╪══════════════╡
  │ 12 dbc 3xy ┆ 0            │
  │ cat\w      ┆ 0            │
  │ 1zy3\d\d   ┆ 2            │
  │ null       ┆ null         │
  └────────────┴──────────────┘
docstr_tok: ["Count","all","successive","non-overlapping","regex","matches",".","Parameters","--","--","--","--","--","pattern","A","valid","regular","expression","pattern",",","compatible","with","the","`","regex","crate","<","https",":","\/\/docs.rs\/regex\/latest\/regex\/",">","`","_",".","literal","Treat","`","pattern","`","as","a","literal","string",",","not","as","a","regular","expression",".","Returns","--","--","--","-","Expr","Expression","of","data","type",":","class",":","`","UInt32","`",".","Returns","null","if","the","original","value","is","null",".","Examples","--","--","--","--",">",">",">","df","=","pl.DataFrame","(","{","``","foo","''",":","[","``","123","bla","45","asd","''",",","``","xyz","678","910t","''",",","``","bar","''",",","None","]","}",")",">",">",">","df.with_columns","(","...","pl.col","(","``","foo","''",")",".str.count_matches","(","r","''","\\d","''",")",".alias","(","``","count_digits","''",")",",","...",")","shape",":","(","4",",","2",")","\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","foo","\u2506","count_digits","\u2502","\u2502","--","-","\u2506","--","-","\u2502","\u2502","str","\u2506","u32","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","123","bla","45","asd","\u2506","5","\u2502","\u2502","xyz","678","910t","\u2506","6","\u2502","\u2502","bar","\u2506","0","\u2502","\u2502","null","\u2506","null","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518",">",">",">","df","=","pl.DataFrame","(","{","``","bar","''",":","[","``","12","dbc","3xy","''",",","``","cat\\\\w","''",",","``","1zy3\\\\d\\\\d","''",",","None","]","}",")",">",">",">","df.with_columns","(","...","pl.col","(","``","bar","''",")","...",".str.count_matches","(","r","''","\\d","''",",","literal=True",")","...",".alias","(","``","count_digits","''",")",",","...",")","shape",":","(","4",",","2",")","\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","bar","\u2506","count_digits","\u2502","\u2502","--","-","\u2506","--","-","\u2502","\u2502","str","\u2506","u32","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","12","dbc","3xy","\u2506","0","\u2502","\u2502","cat\\w","\u2506","0","\u2502","\u2502","1zy3\\d\\d","\u2506","2","\u2502","\u2502","null","\u2506","null","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"]
code: def count_matches(
      self, pattern: str | Expr, *, literal: bool = False
  ) -> Expr:
      r"""
      Count all successive non-overlapping regex matches.
  
      Parameters
      ----------
      pattern
          A valid regular expression pattern, compatible with the `regex crate
          <https://docs.rs/regex/latest/regex/>`_.
      literal
          Treat `pattern` as a literal string, not as a regular expression.
  
      Returns
      -------
      Expr
          Expression of data type :class:`UInt32`. Returns null if the
          original value is null.
  
      Examples
      --------
      >>> df = pl.DataFrame({"foo": ["123 bla 45 asd", "xyz 678 910t", "bar", None]})
      >>> df.with_columns(
      ...     pl.col("foo").str.count_matches(r"\d").alias("count_digits"),
      ... )
      shape: (4, 2)
      ┌────────────────┬──────────────┐
      │ foo            ┆ count_digits │
      │ ---            ┆ ---          │
      │ str            ┆ u32          │
      ╞════════════════╪══════════════╡
      │ 123 bla 45 asd ┆ 5            │
      │ xyz 678 910t   ┆ 6            │
      │ bar            ┆ 0            │
      │ null           ┆ null         │
      └────────────────┴──────────────┘
  
      >>> df = pl.DataFrame({"bar": ["12 dbc 3xy", "cat\\w", "1zy3\\d\\d", None]})
      >>> df.with_columns(
      ...     pl.col("bar")
      ...     .str.count_matches(r"\d", literal=True)
      ...     .alias("count_digits"),
      ... )
      shape: (4, 2)
      ┌────────────┬──────────────┐
      │ bar        ┆ count_digits │
      │ ---        ┆ ---          │
      │ str        ┆ u32          │
      ╞════════════╪══════════════╡
      │ 12 dbc 3xy ┆ 0            │
      │ cat\w      ┆ 0            │
      │ 1zy3\d\d   ┆ 2            │
      │ null       ┆ null         │
      └────────────┴──────────────┘
  
      """
      pattern = parse_as_expression(pattern, str_as_lit=True)
      return wrap_expr(self._pyexpr.str_count_matches(pattern, literal))
  
imports: from __future__ import annotations
  import warnings
  from typing import TYPE_CHECKING
  import polars._reexport
  from polars import functions
  from polars.datatypes import Date, Datetime, Int32, Time, py_type_to_dtype
  from polars.exceptions import ChronoFormatWarning
  from polars.utils._parse_expr_input import parse_as_expression
  from polars.utils._wrap import wrap_expr
  from polars.utils.deprecation import deprecate_renamed_function, deprecate_renamed_parameter, rename_use_earliest_to_ambiguous
  from polars.utils.various import find_stacklevel
label_desc: Use image node_id 31 for calling the ExprStringNameSpace obj's underlying member method code with example usage: obj.count_matches(pattern) and returns: wrap_expr