stringi (version 0.2-5)

stri_extract_all_charclass: Extract Character Class Matches

Description

These functions extract substrings of str that consists of characters from character classes specified by pattern.

Generally, this is the way to extract single characters, only. Longer substrings, however, may be extracted, with the stri_extract_all_charclass function and merge=TRUE.

Usage

stri_extract_all_charclass(str, pattern, merge = TRUE)

stri_extract_first_charclass(str, pattern)

stri_extract_last_charclass(str, pattern)

Arguments

str
character vector to search in
pattern
character vector specifying character classes to match, see stringi-search-charclass
merge
logical [stri_extract_all_charclass only]; should consecutive matches be merged into one string?

Value

  • For stri_extract_all_charclass, a list of max(length(str), length(pattern), length(merge)) character vectors is returned. Otherwise, you get a character vector. NA if not found.

Details

Vectorized over str, pattern, and merge.

See Also

Other search_charclass: stri_count_charclass; stri_detect_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_split_charclass; stri_trim, stri_trim, stri_trim_both, stri_trim_left, stri_trim_right; stringi-search-charclass; stringi-search

Other search_extract: stri_extract_all_coll, stri_extract_first_coll, stri_extract_first_coll, stri_extract_last_coll, stri_extract_last_coll; stri_extract_all_regex, stri_extract_first_regex, stri_extract_first_regex, stri_extract_last_regex, stri_extract_last_regex; stri_extract_all; stri_extract_first; stri_extract_last; stri_extract_words; stri_extract; stringi-search

Examples

Run this code
if (stri_install_check(silent=TRUE))
stri_extract_all_charclass(c('AbcdeFgHijK', 'abc', 'ABC'), '\\p{Ll}')

if (stri_install_check(silent=TRUE))
stri_extract_all_charclass(c('AbcdeFgHijK', 'abc', 'ABC'), '\\p{Ll}', merge=FALSE)

if (stri_install_check(silent=TRUE))
stri_extract_first_charclass('AaBbCc', '\\p{Ll}')

if (stri_install_check(silent=TRUE))
stri_extract_last_charclass('AaBbCc', '\\p{Ll}')

Run the code above in your browser using DataCamp Workspace