class_docstr: Namespace for string related expressions.
class_docstr_tok: ["Namespace","for","string","related","expressions","."]
docstr: Check if string contains a substring that matches a regex.
  
  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.
  strict
      Raise an error if the underlying pattern is not a valid regex,
      otherwise mask out with a null value.
  
  Notes
  -----
  To modify regular expression behaviour (such as case-sensitivity) with
  flags, use the inline `(?iLmsuxU)` syntax. For example:
  
  >>> pl.DataFrame({"s": ["AAA", "aAa", "aaa"]}).with_columns(
  ...     default_match=pl.col("s").str.contains("AA"),
  ...     insensitive_match=pl.col("s").str.contains("(?i)AA"),
  ... )
  shape: (3, 3)
  ┌─────┬───────────────┬───────────────────┐
  │ s   ┆ default_match ┆ insensitive_match │
  │ --- ┆ ---           ┆ ---               │
  │ str ┆ bool          ┆ bool              │
  ╞═════╪═══════════════╪═══════════════════╡
  │ AAA ┆ true          ┆ true              │
  │ aAa ┆ false         ┆ true              │
  │ aaa ┆ false         ┆ true              │
  └─────┴───────────────┴───────────────────┘
  
  See the regex crate's section on `grouping and flags
  <https://docs.rs/regex/latest/regex/#grouping-and-flags>`_ for
  additional information about the use of inline expression modifiers.
  
  See Also
  --------
  starts_with : Check if string values start with a substring.
  ends_with : Check if string values end with a substring.
  
  Examples
  --------
  >>> df = pl.DataFrame({"a": ["Crab", "cat and dog", "rab$bit", None]})
  >>> df.select(
  ...     pl.col("a"),
  ...     pl.col("a").str.contains("cat|bit").alias("regex"),
  ...     pl.col("a").str.contains("rab$", literal=True).alias("literal"),
  ... )
  shape: (4, 3)
  ┌─────────────┬───────┬─────────┐
  │ a           ┆ regex ┆ literal │
  │ ---         ┆ ---   ┆ ---     │
  │ str         ┆ bool  ┆ bool    │
  ╞═════════════╪═══════╪═════════╡
  │ Crab        ┆ false ┆ false   │
  │ cat and dog ┆ true  ┆ false   │
  │ rab$bit     ┆ true  ┆ true    │
  │ null        ┆ null  ┆ null    │
  └─────────────┴───────┴─────────┘
docstr_tok: ["Check","if","string","contains","a","substring","that","matches","a","regex",".","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",".","strict","Raise","an","error","if","the","underlying","pattern","is","not","a","valid","regex",",","otherwise","mask","out","with","a","null","value",".","Notes","--","--","-","To","modify","regular","expression","behaviour","(","such","as","case-sensitivity",")","with","flags",",","use","the","inline","`","(","?","iLmsuxU",")","`","syntax",".","For","example",":",">",">",">","pl.DataFrame","(","{","``","s","''",":","[","``","AAA","''",",","``","aAa","''",",","``","aaa","''","]","}",")",".with_columns","(","...","default_match=pl.col","(","``","s","''",")",".str.contains","(","``","AA","''",")",",","...","insensitive_match=pl.col","(","``","s","''",")",".str.contains","(","``","(","?","i",")","AA","''",")",",","...",")","shape",":","(","3",",","3",")","\u250c\u2500\u2500\u2500\u2500\u2500\u252c\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\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","s","\u2506","default_match","\u2506","insensitive_match","\u2502","\u2502","--","-","\u2506","--","-","\u2506","--","-","\u2502","\u2502","str","\u2506","bool","\u2506","bool","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u256a\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\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","AAA","\u2506","true","\u2506","true","\u2502","\u2502","aAa","\u2506","false","\u2506","true","\u2502","\u2502","aaa","\u2506","false","\u2506","true","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2534\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\u2500\u2500\u2500\u2500\u2500\u2518","See","the","regex","crate","'s","section","on","`","grouping","and","flags","<","https",":","\/\/docs.rs\/regex\/latest\/regex\/","#","grouping-and-flags",">","`","_","for","additional","information","about","the","use","of","inline","expression","modifiers",".","See","Also","--","--","--","--","starts_with",":","Check","if","string","values","start","with","a","substring",".","ends_with",":","Check","if","string","values","end","with","a","substring",".","Examples","--","--","--","--",">",">",">","df","=","pl.DataFrame","(","{","``","a","''",":","[","``","Crab","''",",","``","cat","and","dog","''",",","``","rab","$","bit","''",",","None","]","}",")",">",">",">","df.select","(","...","pl.col","(","``","a","''",")",",","...","pl.col","(","``","a","''",")",".str.contains","(","``","cat|bit","''",")",".alias","(","``","regex","''",")",",","...","pl.col","(","``","a","''",")",".str.contains","(","``","rab","$","''",",","literal=True",")",".alias","(","``","literal","''",")",",","...",")","shape",":","(","4",",","3",")","\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","a","\u2506","regex","\u2506","literal","\u2502","\u2502","--","-","\u2506","--","-","\u2506","--","-","\u2502","\u2502","str","\u2506","bool","\u2506","bool","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","Crab","\u2506","false","\u2506","false","\u2502","\u2502","cat","and","dog","\u2506","true","\u2506","false","\u2502","\u2502","rab","$","bit","\u2506","true","\u2506","true","\u2502","\u2502","null","\u2506","null","\u2506","null","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"]
code: def contains(
      self,
      pattern: str | Expr,
      *,
      literal: bool = False,
      strict: bool = True,
  ) -> Expr:
      """
      Check if string contains a substring that matches a regex.
  
      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.
      strict
          Raise an error if the underlying pattern is not a valid regex,
          otherwise mask out with a null value.
  
      Notes
      -----
      To modify regular expression behaviour (such as case-sensitivity) with
      flags, use the inline `(?iLmsuxU)` syntax. For example:
  
      >>> pl.DataFrame({"s": ["AAA", "aAa", "aaa"]}).with_columns(
      ...     default_match=pl.col("s").str.contains("AA"),
      ...     insensitive_match=pl.col("s").str.contains("(?i)AA"),
      ... )
      shape: (3, 3)
      ┌─────┬───────────────┬───────────────────┐
      │ s   ┆ default_match ┆ insensitive_match │
      │ --- ┆ ---           ┆ ---               │
      │ str ┆ bool          ┆ bool              │
      ╞═════╪═══════════════╪═══════════════════╡
      │ AAA ┆ true          ┆ true              │
      │ aAa ┆ false         ┆ true              │
      │ aaa ┆ false         ┆ true              │
      └─────┴───────────────┴───────────────────┘
  
      See the regex crate's section on `grouping and flags
      <https://docs.rs/regex/latest/regex/#grouping-and-flags>`_ for
      additional information about the use of inline expression modifiers.
  
      See Also
      --------
      starts_with : Check if string values start with a substring.
      ends_with : Check if string values end with a substring.
  
      Examples
      --------
      >>> df = pl.DataFrame({"a": ["Crab", "cat and dog", "rab$bit", None]})
      >>> df.select(
      ...     pl.col("a"),
      ...     pl.col("a").str.contains("cat|bit").alias("regex"),
      ...     pl.col("a").str.contains("rab$", literal=True).alias("literal"),
      ... )
      shape: (4, 3)
      ┌─────────────┬───────┬─────────┐
      │ a           ┆ regex ┆ literal │
      │ ---         ┆ ---   ┆ ---     │
      │ str         ┆ bool  ┆ bool    │
      ╞═════════════╪═══════╪═════════╡
      │ Crab        ┆ false ┆ false   │
      │ cat and dog ┆ true  ┆ false   │
      │ rab$bit     ┆ true  ┆ true    │
      │ null        ┆ null  ┆ null    │
      └─────────────┴───────┴─────────┘
  
      """
      pattern = parse_as_expression(pattern, str_as_lit=True)
      return wrap_expr(
          self._pyexpr.str_contains(pattern, literal, strict)
      )
  
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 21 for calling the ExprStringNameSpace obj's underlying member method code with example usage: obj.contains(pattern) and returns: wrap_expr