Skip to contents

This function is mostly a wrapper around str_squish, with the additional option to remove hyphens at the ends of lines.

Usage

squish_whitespace(text, remove_terminal_hyphens = TRUE)

Arguments

text

A character vector to clean.

remove_terminal_hyphens

Logical; should hyphens at the end of lines after a word be removed? For example, "un-\nbroken" would become "unbroken".

Value

The character vector with spacing at the start and end removed, and with internal spacing reduced to a single space character each.

Examples

sample_text <- "This  had many space char-\\nacters."
squish_whitespace(sample_text)
#> [1] "This had many space char-\\nacters."