stringi (version 0.3-1)

stri_subset: Select Elements that Match a Given Pattern

Description

These functions return a subvector consisting of strings that match a given pattern. In other words, they are roughly equivalent (but faster and easier to use) to a call to str[stri_detect(str, ...)].

Usage

stri_subset(str, ..., regex, fixed, coll, charclass)

stri_subset_fixed(str, pattern)

stri_subset_charclass(str, pattern)

stri_subset_coll(str, pattern, opts_collator = NULL)

stri_subset_regex(str, pattern, opts_regex = NULL)

Arguments

str
character vector with strings to search in
...
additional arguments passed to the underlying functions; stri_subset only
pattern,regex,fixed,coll,charclass
character vector defining search patterns; for more details refer to stringi-search
opts_collator
a named list with ICU Collator's settings as generated with stri_opts_collator; NULL for default settings; stri_subset_coll only
opts_regex
a named list with ICU Regex settings as generated with stri_opts_regex; NULL for default settings; stri_subset_regex only

Value

  • All the functions return a character vector. Of course, the output encoding is always UTF-8.

Details

Vectorized over str and pattern.

stri_subset is a convenience function. It calls either stri_subset_regex, stri_subset_fixed, stri_subset_coll, or stri_subset_charclass, depending on the argument used. Unless you are a very lazy person, please call the underlying functions directly for better performance.

See Also

Other search_subset: stringi-search

Examples

Run this code
stri_subset_fixed(c("stringi R", "REXAMINE", "123"), c('i', 'R', '0'))
stri_subset_fixed(c("stringi R", "REXAMINE", "123"), 'R')
stri_subset_charclass(c("stRRRingi","REXAMINE","123"),
   c("\\p{Ll}", "\\p{Lu}", "\\p{Zs}"))

Run the code above in your browser using DataLab