Skip to content

Strip prefix

Description

The prefix will be removed from the string exactly once, if found.

Usage

<Expr>$str$strip_prefix(prefix = NULL)

Arguments

prefix The prefix to be removed.

Details

This method strips the exact character sequence provided in prefix from the start of the input. To strip a set of characters in any order, use $strip_chars_start() instead.

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(a = c("foobar", "foofoobar", "foo", "bar"))
df$with_columns(
  stripped = pl$col("a")$str$strip_prefix("foo")
)
#> shape: (4, 2)
#> ┌───────────┬──────────┐
#> │ a         ┆ stripped │
#> │ ---       ┆ ---      │
#> │ str       ┆ str      │
#> ╞═══════════╪══════════╡
#> │ foobar    ┆ bar      │
#> │ foofoobar ┆ foobar   │
#> │ foo       ┆          │
#> │ bar       ┆ bar      │
#> └───────────┴──────────┘