Skip to contents

strs_removesuffix removes a specified suffix from the end of each element of a character vector. It is similar to Python's str.removesuffix() method.

Usage

strs_removesuffix(string, suffix)

Arguments

string

A character vector where each element is a string from which to remove the suffix.

suffix

The suffix to remove.

Value

A character vector of the same length as string, with the suffix removed from each element.

Examples

strs_removesuffix("StringTest", "Test")
#> [1] "String"
strs_removesuffix("hello world", "world")
#> [1] "hello "