Count matches
str_count()
: returns how many matches there are in each string.
- each match starts at the end of the previous match, regex matches don’t overlap.
x <- c("apple", "banana", "pear")
str_count(x, "p")
## [1] 2 0 1
str_count("abababa", "aba")
## [1] 2
str_view("abababa", "aba")
## [1] │ <aba>b<aba>