stri_count_fixed: Count the Number of Fixed Pattern Matches

Description Usage Arguments Details Value See Also Examples

Description

This function counts the number of occurrences of a fixed pattern in a string.

Usage

1
stri_count_fixed(str, pattern, opts_collator = list())

Arguments

str

character vector

pattern

character vector

opts_collator

a named list as generated with stri_opts_collator with Collator options, or NA for fast but locale-unaware byte comparison

Details

Vectorized over str and pattern.

If pattern is empty, then the result is NA and a warning is generated.

See stringi-search-fixed for more details on Locale-Sensitive Text Searching in stringi.

Pass opts_collator equal to NA for much faster, but locale unaware, (exact) byte comparisons. For natural language text this may be not what you really want.

Value

Returns an integer vector with the number of matches.

See Also

Other locale_sensitive: stri_cmp, stri_compare; stri_detect_fixed; stri_enc_detect2; stri_locate_all_fixed, stri_locate_all_fixed,, stri_locate_first_fixed, stri_locate_first_fixed,, stri_locate_last_fixed, stri_locate_last_fixed; stri_opts_collator; stri_order, stri_sort; stri_replace_all_fixed, stri_replace_all_fixed, stri_replace_first_fixed, stri_replace_first_fixed, stri_replace_last_fixed, stri_replace_last_fixed; stri_split_fixed, stri_split_fixed; stri_trans_tolower, stri_trans_totitle, stri_trans_toupper; stringi-locale; stringi-search-fixed

Other search_count: stri_count_charclass; stri_count_regex; stri_count; stringi-search

Other search_fixed: stri_detect_fixed; stri_extract_all_fixed, stri_extract_all_fixed,, stri_extract_first_fixed, stri_extract_first_fixed,, stri_extract_last_fixed, stri_extract_last_fixed; stri_locate_all_fixed, stri_locate_all_fixed,, stri_locate_first_fixed, stri_locate_first_fixed,, stri_locate_last_fixed, stri_locate_last_fixed; stri_opts_collator; stri_replace_all_fixed, stri_replace_all_fixed, stri_replace_first_fixed, stri_replace_first_fixed, stri_replace_last_fixed, stri_replace_last_fixed; stri_split_fixed, stri_split_fixed; stringi-search-fixed; stringi-search

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
s <- "Lorem ipsum dolor sit amet, consectetur adipisicing elit."
stri_count_fixed(s, " ")
stri_count_fixed(s, "o")
stri_count_fixed(s, "it")
stri_count_fixed(s, letters)
stri_count_fixed("babab", "b")
stri_count_fixed(c("stringi w R","REXAMINE","123"), 'R')

## End(Not run)

Example output

[1] 7
[1] 4
[1] 2
 [1] 2 0 3 2 5 0 1 0 7 0 0 2 3 2 4 2 0 3 4 5 2 0 0 0 0 0
[1] 3
[1] 1 1 0

stringi documentation built on May 2, 2019, 4:54 p.m.