| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/string.R |
| 3 |
\name{split_lines} |
| 4 |
\alias{split_lines} |
| 5 |
\title{Split a character vector by line breaks} |
| 6 |
\usage{ |
| 7 |
split_lines(x) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{x}{A character vector.} |
| 11 |
} |
| 12 |
\value{ |
| 13 |
All elements of the character vector are split by \code{'\\n'} into |
| 14 |
lines. |
| 15 |
} |
| 16 |
\description{ |
| 17 |
Call \code{unlist(strsplit(x, '\\n'))} on the character vector \code{x} and |
| 18 |
make sure it works in a few edge cases: \code{split_lines('')} returns |
| 19 |
\code{''} instead of \code{character(0)} (which is the returned value of |
| 20 |
\code{strsplit('', '\\n')}); \code{split_lines('a\\n')} returns \code{c('a', '')} instead of \code{c('a')} (which is the returned value of |
| 21 |
\code{strsplit('a\\n', '\\n')}. |
| 22 |
} |
| 23 |
\examples{ |
| 24 |
xfun::split_lines(c("a", "b\nc")) |
| 25 |
} |