stri_split_boundaries {stringi} | R Documentation |
This function locates specific text boundaries (like character, word, line, or sentence boundaries) and splits strings at the indicated positions.
stri_split_boundaries(str, n = -1L, tokens_only = FALSE, simplify = FALSE, ..., opts_brkiter = NULL)
str |
character vector or an object coercible to |
n |
integer vector, maximal number of strings to return |
tokens_only |
single logical value; may affect the result if |
simplify |
single logical value; if |
... |
additional settings for |
opts_brkiter |
a named list with ICU BreakIterator's settings
as generated with |
Vectorized over str
and n
.
If n
is negative (default), then all pieces are extracted.
Otherwise, if tokens_only
is FALSE
(this is the default,
for compatibility with the stringr package), then n-1
tokes are extracted (if possible) and the n
-th string
gives the (non-split) remainder (see Examples).
On the other hand, if tokens_only
is TRUE
,
then only full tokens (up to n
pieces) are extracted.
For more information on the text boundary analysis
performed by ICU's BreakIterator
, see
stringi-search-boundaries.
If simplify=FALSE
(the default),
then the functions return a list of character vectors.
Otherwise, stri_list2matrix
with byrow=TRUE
and n_min=n
arguments is called on the resulting object.
In such a case, a character matrix with length(str)
rows
is returned. Note that stri_list2matrix
's fill
argument is set to an empty string and NA
,
for simplify
equal to TRUE
and NA
, respectively.
Other locale_sensitive: %s!==%
,
%s!=%
, %s<=%
,
%s<%
, %s===%
,
%s==%
, %s>=%
,
%s>%
, %stri!==%
,
%stri!=%
, %stri<=%
,
%stri<%
, %stri===%
,
%stri==%
, %stri>=%
,
%stri>%
; stri_cmp
,
stri_cmp_eq
, stri_cmp_equiv
,
stri_cmp_ge
, stri_cmp_gt
,
stri_cmp_le
, stri_cmp_lt
,
stri_cmp_neq
,
stri_cmp_nequiv
,
stri_compare
;
stri_count_boundaries
,
stri_count_words
;
stri_duplicated
,
stri_duplicated_any
;
stri_enc_detect2
;
stri_extract_all_boundaries
,
stri_extract_all_words
,
stri_extract_first_boundaries
,
stri_extract_first_words
,
stri_extract_last_boundaries
,
stri_extract_last_words
;
stri_locate_all_boundaries
,
stri_locate_all_words
,
stri_locate_first_boundaries
,
stri_locate_first_words
,
stri_locate_last_boundaries
,
stri_locate_last_words
;
stri_opts_collator
;
stri_order
, stri_sort
;
stri_trans_tolower
,
stri_trans_totitle
,
stri_trans_toupper
;
stri_unique
; stri_wrap
;
stringi-locale
;
stringi-search-boundaries
;
stringi-search-coll
Other search_split: stri_split_lines
,
stri_split_lines1
,
stri_split_lines1
;
stri_split
,
stri_split_charclass
,
stri_split_coll
,
stri_split_fixed
,
stri_split_regex
;
stringi-search
Other text_boundaries: stri_count_boundaries
,
stri_count_words
;
stri_extract_all_boundaries
,
stri_extract_all_words
,
stri_extract_first_boundaries
,
stri_extract_first_words
,
stri_extract_last_boundaries
,
stri_extract_last_words
;
stri_locate_all_boundaries
,
stri_locate_all_words
,
stri_locate_first_boundaries
,
stri_locate_first_words
,
stri_locate_last_boundaries
,
stri_locate_last_words
;
stri_opts_brkiter
;
stri_split_lines
,
stri_split_lines1
,
stri_split_lines1
;
stri_trans_tolower
,
stri_trans_totitle
,
stri_trans_toupper
;
stri_wrap
;
stringi-search-boundaries
;
stringi-search
test <- "The\u00a0above-mentioned features are very useful. " %s+% "Warm thanks to their developers. 123 456 789" stri_split_boundaries(test, type="line") stri_split_boundaries(test, type="word") stri_split_boundaries(test, type="word", skip_word_none=TRUE) stri_split_boundaries(test, type="word", skip_word_none=TRUE, skip_word_letter=TRUE) stri_split_boundaries(test, type="word", skip_word_none=TRUE, skip_word_number=TRUE) stri_split_boundaries(test, type="sentence") stri_split_boundaries(test, type="sentence", skip_sentence_sep=TRUE) stri_split_boundaries(test, type="character")