Products, services, and OS functions
may not be available in this country.

COUNTMATCHES

The COUNTMATCHES function returns a number value representing the number of times a given substring appears in the original string value.

COUNTMATCHES(source-string, search-string)

source-string: Any value.

search-string: The string value to search for.

Notes

  • COUNTMATCHES counts overlapping matches as separate occurrences (=COUNTMATCHES("asasa", "asa") returns 2).

  • REGEX is permitted in search-string for more complex searches.

  • By default, the search isn't case sensitive. To consider case in your search, use the REGEX function for search-string.

Examples

=COUNTMATCHES("Please, could you, if you don’t mind, count the number of commas?", ",") returns 3.

=COUNTMATCHES("To count all words, use regex.", REGEX("\w+")) returns 6.

=COUNTMATCHES(A1, REGEX("\w+")) returns the number of words in A1.

See alsoREGEX
Morty Proxy This is a proxified and sanitized view of the page, visit original site.
Helpful?
Character limit: 250
Maximum character limit is 250.
Thanks for your feedback.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.