Skip to contents

strs_removeprefix removes a specified prefix from the start of each element of a character vector. It is similar to Python's str.removeprefix() method.

Usage

strs_removeprefix(string, prefix)

Arguments

string

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

prefix

The prefix to remove.

Value

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

Examples

strs_removeprefix("testString", "test")
#> [1] "String"
strs_removeprefix("hello world", "hello")
#> [1] " world"