ac_count_file() returns the number of pattern matches in each file.
Arguments
- ac
An
<ac_automaton>object created byac_build().- path
A vector of file paths to search.
- stream
If
FALSE(default), each file is read into memory before searching. IfTRUE, files are searched as streams. Stream search requires an automaton built withmatch_kind = "standard".- overlapping
Default is
FALSE. IfTRUE, count overlapping matches. This is only supported whenstream = FALSEandacwas built withmatch_kind = "standard".
Examples
ac <- ac_build(c("hello", "world"))
path <- tempfile()
writeLines("hello hello world", path)
ac_count_file(ac, path)
#> [1] 3