Skip to main content
Version: 1.2.0

Expr.str.contains

def contains(pattern: str | Expr, literal: bool = False, strict: bool = True) -> Expr

Categories: string

Evaluate if the string contains a pattern.

Parameters

parameter
pattern

The pattern to search for.

parameter
literal

Take the pattern as a literal string (not a regex).

parameter
strict

if the given pattern is not valid regex, raise an error.

Examples

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.contains("ab").alias("contains"))
>>>
┌──────┬──────────┐
│ a ┆ contains │
------
strbool
╞══════╪══════════╡
│ a ┆ false │
│ ab ┆ true │
│ b ┆ false │
│ xaby ┆ true │
│ null ┆ null │
└──────┴──────────┘