stringi (version 0.2-5)

stri_locate_all_coll: Locate Occurrences of a Canonically Equivalent Pattern

Description

These functions find the indices, at which a given pattern matches a substring of the input string.

Usage

stri_locate_all_coll(str, pattern, opts_collator = NULL)

stri_locate_first_coll(str, pattern, opts_collator = NULL)

stri_locate_last_coll(str, pattern, opts_collator = NULL)

Arguments

str
character vector
pattern
character vector
opts_collator
a named list with ICU Collator's settings as generated with stri_opts_collator; NULL for default settings

Value

  • For stri_locate_all_coll, 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 gen two NAs in one row for no match or NA arguments.

    For stri_locate_first_coll and stri_locate_last_coll, 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 NAs iff not found.

Details

Vectorized over str and pattern.

See stringi-search-coll for more details on locale-sensitive text searching in stringi.

Note the difference between stri_locate_last_coll and stri_locate_last_regex for overlapping pattern matches. In stri_locate_last_coll, search is done from-the-end.

See Also

Other indexing: stri_locate_all_charclass, stri_locate_first_charclass, stri_locate_first_charclass, stri_locate_last_charclass, stri_locate_last_charclass; 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 locale_sensitive: %!==%, %!=%, %<=%< a="">, %<%< a="">, %===%, %==%, %>=%, %>%, %stri!==%, %stri!=%, %stri<=%< a="">, %stri<%< a="">, %stri===%, %stri==%, %stri>=%, %stri>%; stri_cmp, stri_cmp_eq, stri_cmp_equiv, stri_cmp_ge, stri_cmp_gt, stri_cmp_le, stri_cmp_lt, stri_cmp_neq, stri_cmp_nequiv, stri_compare; stri_count_coll; stri_detect_coll; stri_duplicated, stri_duplicated_any; stri_enc_detect2; stri_extract_all_coll, stri_extract_first_coll, stri_extract_first_coll, stri_extract_last_coll, stri_extract_last_coll; stri_extract_words; stri_locate_boundaries; stri_locate_words; stri_opts_collator; stri_order, stri_sort; stri_replace_all_coll, stri_replace_first_coll, stri_replace_first_coll, stri_replace_last_coll, stri_replace_last_coll; stri_split_boundaries; stri_split_coll; stri_trans_tolower, stri_trans_totitle, stri_trans_toupper; stri_unique; stri_wrap; stringi-locale; stringi-search-coll

Other search_coll: stri_count_coll; stri_detect_coll; stri_extract_all_coll, stri_extract_first_coll, stri_extract_first_coll, stri_extract_last_coll, stri_extract_last_coll; stri_replace_all_coll, stri_replace_first_coll, stri_replace_first_coll, stri_replace_last_coll, stri_replace_last_coll; stri_split_coll; stringi-search-coll; stringi-search

Other search_locate: stri_locate_all_charclass, stri_locate_first_charclass, stri_locate_first_charclass, stri_locate_last_charclass, stri_locate_last_charclass; 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_coll(c('AaaaaaaA', 'AAAA'), 'a')

if (stri_install_check(silent=TRUE))
stri_locate_first_coll(c('AaaaaaaA', 'aaa', 'AAA'), 'a')

if (stri_install_check(silent=TRUE))
stri_locate_last_coll(c('AaaaaaaA', 'aaa', 'AAA'), 'a')


if (stri_install_check(silent=TRUE))
#first row is 1-2 like in locate_first
stri_locate_all_coll('bbbbb', 'bb')

if (stri_install_check(silent=TRUE))
stri_locate_first_coll('bbbbb', 'bb')

if (stri_install_check(silent=TRUE))
# but last row is 3-4, unlike in locate_last,
# keep this in mind [overlapping pattern match OK]!
stri_locate_last_coll('bbbbb', 'bb')

Run the code above in your browser using DataCamp Workspace