strs_strip: Strip characters from both ends of a string

View source: R/strip.R

strs_stripR Documentation

Strip characters from both ends of a string

Description

strs_strip removes leading and trailing characters (spaces by default) from each element of a character vector. It is similar to Python's str.strip() method.

Usage

strs_strip(string, chars = NULL)

Arguments

string

A character vector where each element is a string to be stripped.

chars

An optional string of characters to be removed from both ends of each element. If NULL, whitespace is removed.

Value

A character vector of the same length as string, with specified characters removed from both ends of each element.

See Also

Python str.strip() documentation

Examples

strs_strip("    hello world    ")
strs_strip("xxxyhello worldyyy", chars = "xy")

strs documentation built on Sept. 11, 2024, 6:44 p.m.