str_squish_line_breaks | R Documentation |
Removes line breaks (\n and \r) from the start and end of a string and
repeated line breaks inside a string.
This is an analogue of stringr::str_squish(), which trims white space from the start and end of a string and removes repeated whitespace inside a string. However stringr::str_squish() will replace line breaks inside a string with a space, which is not always desired.
Note that if there is a repeat of two different line break characters, i.e. a newline (\n) and line return (\r), the first occurrence will be kept.
See: https://github.com/tidyverse/stringr/issues/477
str_squish_line_breaks(string)
string |
String to squish |
String with repeeated line returns and whitespaces removed
stringr::str_squish("hello\nworld")
stringr::str_squish("hello\n\nworld")
str_squish_line_breaks("hello\nworld")
str_squish_line_breaks("hello\n\nworld")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.