v.21.1New Features

Add countMatches and countMatchesCaseInsensitive functions

Add functions countMatches/countMatchesCaseInsensitive. #17459 (Azat Khuzhin).
Added new functions countMatches and countMatchesCaseInsensitive to count occurrences of a substring or pattern in a given string with case-sensitive and case-insensitive options respectively.

Why it matters

These functions solve the problem of efficiently counting how many times a substring or regex pattern appears within a string. This enhances text processing capabilities in ClickHouse by providing an easy way to perform frequency analysis directly within SQL queries.

How to use it

Use the functions countMatches(haystack, needle) for case-sensitive counting and countMatchesCaseInsensitive(haystack, needle) for case-insensitive counting where haystack is the string to search in and needle is the substring or regex pattern to count.