Split up a String by a Character Class

Share:

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

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

Arguments

str

character vector with strings to search in

pattern

character vector; identifiers of character classes, 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

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.

Value

Returns a list of character vectors.

See Also

Other search_charclass: stri_count_charclass; stri_detect_charclass; stri_extract_all_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_all_charclass, stri_locate_first_charclass, stri_locate_first_charclass, stri_locate_last_charclass, stri_locate_last_charclass; stri_replace_all_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_fixed, stri_split_fixed; stri_split_lines, stri_split_lines, stri_split_lines1, stri_split_lines1; stri_split_regex, stri_split_regex; stri_split; stringi-search

Examples

1
2
3
stri_split_charclass("Lorem ipsum dolor sit amet", "WHITE_SPACE")
stri_split_charclass(" Lorem  ipsum dolor", "WHITE_SPACE", n=3,
   omit_empty=c(FALSE, TRUE))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.