split_nth | R Documentation |
Split a string at the n
th occurrence(s) of a pattern
.
split_nth(text, pattern, n = NULL, keep_split = FALSE, repl = "$$$", ...)
text , pattern |
the text and pattern character strings |
n |
integer value(s) for splitting at the |
keep_split |
logical; if |
repl |
a string used internally for place-keeping during splitting;
to avoid unexpected results, make sure this string does not occur in
|
... |
additional arguments passed to |
s <- 'this is a test string to use for testing purposes'
split_nth(s, '\\s+')
split_nth(s, '\\s+', 3)
split_nth(s, '\\s+', c(3, 5))
split_nth(s, '\\s+', c(3, 5), keep_split = TRUE)
split_nth(s, '\\s{2,}', keep_split = TRUE)
split_nth(s, '\\s{2,}', 2:4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.