stringi (version 0.2-5)

stri_split_charclass: Split a String by a Character Class

Description

Splits each element of str into substrings. pattern indicates delimiters that separate the input into fields. The input data between the matches become the fields themselves.

Usage

stri_split_charclass(str, pattern, n_max = -1L, omit_empty = FALSE)

Arguments

str
character vector with strings to search in
pattern
character vector specifying character classes to match, see stringi-search-charclass
n_max
integer vector, maximal number of pieces to return
omit_empty
logical vector; determines whether empty strings should be removed from the result

Value

  • Returns a list of character vectors.

Details

Vectorized over str, pattern, n_max, and omit_empty.

If n_max is negative (default), then all pieces are extracted.

omit_empty is applied during the split process: if it is set to TRUE, then empty strings will never appear in the resulting vector.

See Also

Other search_charclass: stri_count_charclass; stri_detect_charclass; stri_extract_all_charclass, stri_extract_first_charclass, stri_extract_first_charclass, stri_extract_last_charclass, stri_extract_last_charclass; stri_locate_all_charclass, stri_locate_first_charclass, stri_locate_first_charclass, stri_locate_last_charclass, stri_locate_last_charclass; stri_replace_all_charclass, stri_replace_first_charclass, stri_replace_first_charclass, stri_replace_last_charclass, stri_replace_last_charclass; stri_trim, stri_trim, stri_trim_both, stri_trim_left, stri_trim_right; stringi-search-charclass; stringi-search

Other search_split: stri_split_boundaries; stri_split_coll; stri_split_fixed; stri_split_lines, stri_split_lines1, stri_split_lines1; stri_split_regex; stri_split; stringi-search

Examples

Run this code
if (stri_install_check(silent=TRUE))
stri_split_charclass("Lorem ipsum dolor sit amet", "\\p{WHITE_SPACE}")

if (stri_install_check(silent=TRUE))
stri_split_charclass("Lorem  ipsum dolor", "\\p{WHITE_SPACE}", n=3,
   omit_empty=c(FALSE, TRUE))

Run the code above in your browser using DataLab