Learn R Programming

jwutil (version 1.1.1)

strip: strip all whitespace

Description

could do this with regular expression, but slow, and this function is called frequently. My only use case works with removal of all space character whitespace, and I don't expect <TAB>. This uses non-unicode aware matching for speed. This can be changed by setting useBytes to FALSE.

Usage

strip(x, pattern = " ", useBytes = TRUE)

Arguments

x

is a character vector to strip

pattern

is the non-regex of the character to strip, default " "

useBytes

logical scalar. Unlike gsub, this will default to TRUE here, therefore breaking unicode.

Value

character vector