strs_splitlines
splits each element of a character vector into separate
lines. It is similar to Python's str.splitlines()
method.
Usage
strs_splitlines(string, keepends = FALSE)
Arguments
- string
A character vector to be split into lines.
- keepends
A boolean indicating whether to retain line end characters.
Value
A list of character vectors, with each vector containing lines from
the corresponding element of string
.
Examples
strs_splitlines("hello\nworld\n")
#> [[1]]
#> [1] "hello" "world"
#>
strs_splitlines("line1\r\nline2\n", keepends = TRUE)
#> [[1]]
#> [1] "line1" "line2" ""
#>