Learn R Programming

strs (version 0.1.0)

strs_normalize_whitespace: Normalize whitespace in a string

Description

strs_normalize_whitespace normalizes the whitespace in each element of a character vector. It trims leading and trailing whitespace and replaces any sequence of whitespace characters within the string with a single space. This function is akin to the typical Python pattern " ".join(str.split()).

Usage

strs_normalize_whitespace(string)

Value

A character vector of the same length as string, with whitespace normalized in each element.

Arguments

string

A character vector where each element is a string in which to normalize whitespace.

Examples

Run this code
strs_normalize_whitespace("  hello   world  ")
strs_normalize_whitespace("\thello\nworld\t")

Run the code above in your browser using DataLab