filesstrings (version 2.5.0)

count_matches: Count the number of the matches of a pattern in a string.

Description

Vectorized over string and pattern.

Usage

count_matches(string, pattern)

Arguments

string

A character vector.

pattern

A character vector. Pattern(s) specified like the pattern(s) in the stringr package (e.g. look at stringr::str_locate()). If this has length >1 its length must be the same as that of string.

Value

An integer vector giving the number of matches in each string.

Examples

Run this code
# NOT RUN {
count_matches(c("abacad", "xyz"), "a")
count_matches("2.1.0.13", ".")
count_matches("2.1.0.13", stringr::coll("."))
# }

Run the code above in your browser using DataLab