Count Matching Patterns
STRING

Problem

Given a string patterns representing the patterns of interest and a string collection representing the collected items, count how many items in collection match the patterns.

Note that the matching is case-sensitive.

Examples

countMatches("cD", "cDcDaa") // returns 4 // There are four matches for the // patterns "c" and "D" in the collection. countMatches("x", "XXX") // returns 0 // The pattern "x" does not match any in the "XXX" collection.
Loading...