Skip to content

Strip trailing characters

Source code

Description

Remove trailing characters.

Usage

<Expr>$str$strip_chars_end(matches = NULL)

Arguments

matches The set of characters to be removed. All combinations of this set of characters will be stripped. If NULL (default), all whitespace is removed instead. This can be an Expr.

Details

This function will not strip any chars beyond the first char not matched. strip_chars_end() removes characters at the end of the string only. Use strip_chars() and strip_chars_start() to remove characters from the left and right or only from the left respectively.

Value

Expr of String lowercase chars

Examples

library(polars)

df = pl$DataFrame(foo = c(" hello", "\tworld"))
df$select(pl$col("foo")$str$strip_chars_end(" hel\trld"))
#> shape: (2, 1)
#> ┌────────┐
#> │ foo    │
#> │ ---    │
#> │ str    │
#> ╞════════╡
#> │  hello │
#> │    wo     │
#> └────────┘
df$select(pl$col("foo")$str$strip_chars_end("rldhel\t "))
#> shape: (2, 1)
#> ┌────────┐
#> │ foo    │
#> │ ---    │
#> │ str    │
#> ╞════════╡
#> │  hello │
#> │    wo     │
#> └────────┘