Check if string ends with a regex
Description
Check if string values end with a substring.
Usage
<Expr>$str$ends_with(sub)
Arguments
sub
|
Suffix substring or Expr. |
Details
See also $str$starts_with()
and
$str$contains()
.
Value
Expr of Boolean data type
Examples
library("polars")
df = pl$DataFrame(fruits = c("apple", "mango", NA))
df$select(
pl$col("fruits"),
pl$col("fruits")$str$ends_with("go")$alias("has_suffix")
)
#> shape: (3, 2)
#> ┌────────┬────────────┐
#> │ fruits ┆ has_suffix │
#> │ --- ┆ --- │
#> │ str ┆ bool │
#> ╞════════╪════════════╡
#> │ apple ┆ false │
#> │ mango ┆ true │
#> │ null ┆ null │
#> └────────┴────────────┘