filesstrings (version 0.3.2)

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

Description

Vectorised over string and pattern.

Usage

CountMatches(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

A numeric vector giving the number of matches in each string.

Examples

Run this code
CountMatches("abacad", "a")
CountMatches("2.1.0.13", ".")
CountMatches("2.1.0.13", stringr::coll("."))

Run the code above in your browser using DataLab