stringi (version 0.2-5)

stri_locate_all_charclass: Locate Occurrences of a Character Class

Description

These functions may be used e.g. to find the indices, at which letters, digits, or white spaces occur in a given string.

Usage

stri_locate_all_charclass(str, pattern, merge = TRUE)

stri_locate_first_charclass(str, pattern)

stri_locate_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_locate_all_charclass only]; indicates whether consecutive sequences of indices in the resulting matrix shall be merged

Value

  • For stri_locate_all_charclass, a list of max(length(str), length(pattern)) integer matrices is returned. The first column gives the start positions of matches, and the second column gives the end positions. Moreover, you may get two NAs in one row for no match or NA arguments.

    For stri_locate_first_charclass and stri_locate_last_charclass, you get an integer matrix with max(length(str), length(pattern)) rows, and two columns, giving the start and end positions of the first or the last matches, respectively, and two NAs iff not found. Note that the first column is always equal to the second column, as we look for single code points in these two cases.

Details

Vectorized over str, pattern, and merge.

See Also

Other indexing: stri_locate_all_coll, stri_locate_first_coll, stri_locate_first_coll, stri_locate_last_coll, stri_locate_last_coll; stri_locate_all_fixed, stri_locate_first_fixed, stri_locate_first_fixed, stri_locate_last_fixed, stri_locate_last_fixed; stri_locate_all_regex, stri_locate_first_regex, stri_locate_first_regex, stri_locate_last_regex, stri_locate_last_regex; stri_locate_all; stri_locate_boundaries; stri_locate_first; stri_locate_last; stri_locate_words; stri_locate; stri_sub, stri_sub<-

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_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_locate: stri_locate_all_coll, stri_locate_first_coll, stri_locate_first_coll, stri_locate_last_coll, stri_locate_last_coll; stri_locate_all_fixed, stri_locate_first_fixed, stri_locate_first_fixed, stri_locate_last_fixed, stri_locate_last_fixed; stri_locate_all_regex, stri_locate_first_regex, stri_locate_first_regex, stri_locate_last_regex, stri_locate_last_regex; stri_locate_all; stri_locate_boundaries; stri_locate_first; stri_locate_last; stri_locate_words; stri_locate; stringi-search

Examples

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

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

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

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

if (stri_install_check(silent=TRUE))
stri_locate_all_charclass(c('REXAMINE'), '\\p{Lu}', merge=c(TRUE, FALSE))

Run the code above in your browser using DataLab