Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Switch services using the Version drop-down list. Learn more about navigation.
Applies to: ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
Counts occurrences of a substring in a string. Plain string matches may overlap; regex matches don't.
Syntax
countof(source, search [, kind])
Learn more about syntax conventions.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| source | string |
✔️ | The value to search. |
| search | string |
✔️ | The value or regular expression to match inside source. |
| kind | string |
The value normal or regex. The default is normal. |
Returns
The number of times that the search value can be matched in the source string. Plain string matches may overlap; regex matches don't.
Examples
| Function call | Result |
|---|---|
countof("aaa", "a") |
3 |
countof("aaaa", "aa") |
3 (not 2!) |
countof("ababa", "ab", "normal") |
2 |
countof("ababa", "aba") |
2 |
countof("ababa", "aba", "regex") |
1 |
countof("abcabc", "a.c", "regex") |
2 |