str_trim: Trim whitespace from a string

View source: R/trim.R

str_trimR Documentation

Trim whitespace from a string

Description

str_trim() removes whitespace from start and end of string; str_squish() also reduces repeated whitespace inside a string.

Usage

str_trim(string, side = c("both", "left", "right"))

str_squish(string)

Arguments

string

character vector

side

string, side on which to remove whitespace (left, right or both).

Value

Returns a character vector the same length as string.

See Also

str_pad() to add whitespace

Examples

str_trim("  String with trailing and leading white space\t")
str_trim("\n\nString with trailing and leading white space\n\n")

str_squish("  String with trailing,  middle, and leading white space\t")
str_squish("\n\nString with excess,  trailing and leading white   space\n\n")

csdaw/stringrb documentation built on Aug. 13, 2022, 10:55 p.m.