Examples for 'stringi::stri_count'


Count the Number of Pattern Occurrences

Aliases: stri_count stri_count_charclass stri_count_coll stri_count_fixed stri_count_regex

Keywords:

### ** Examples

s <- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.'
stri_count(s, fixed='dolor')
[1] 1
stri_count(s, regex='\\p{L}+')
[1] 8
stri_count_fixed(s, ' ')
[1] 7
stri_count_fixed(s, 'o')
[1] 4
stri_count_fixed(s, 'it')
[1] 2
stri_count_fixed(s, letters)
 [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
stri_count_fixed('babab', 'b')
[1] 3
stri_count_fixed(c('stringi', '123'), 'string')
[1] 1 0
stri_count_charclass(c('stRRRingi', 'STrrrINGI', '123'),
   c('\\p{Ll}', '\\p{Lu}', '\\p{Zs}'))
[1] 6 6 0
stri_count_charclass(' \t\n', '\\p{WHITE_SPACE}') # white space - binary property
[1] 3
stri_count_charclass(' \t\n', '\\p{Z}') # white-space - general category (note the difference)
[1] 1
stri_count_regex(s, '(s|el)it')
[1] 2
stri_count_regex(s, 'i.i')
[1] 2
stri_count_regex(s, '.it')
[1] 2
stri_count_regex('bab baab baaab', c('b.*?b', 'b.b'))
[1] 3 2
stri_count_regex(c('stringi', '123'), '^(s|1)')
[1] 1 1

[Package stringi version 1.8.4 Index]