matches regex operator

Learn how to use the matches regex string operator to filter a record set based on a case-sensitive regex value.

Filters a record set based on a case-sensitive regular expression value.

For more information about other operators and to determine which operator is most appropriate for your query, see datatype string operators.

Syntax

T | where col matches regex (expression)

Parameters

NameTypeRequiredDescription
Tstring✔️The tabular input whose records are to be filtered.
colstring✔️The column by which to filter.
expressionscalar✔️The regular expression /Query/Data%20types/real.md used to filter. The maximum number of regex groups is 16. For more information about the regex syntax supported by Kusto, see regular expression.

Returns

Rows in T for which the predicate is true.

Example

StormEvents
| summarize event_count=count() by State
| where State matches regex "K.*S"
| where event_count > 10
| project State, event_count

Output

Stateevent_count
KANSAS3166
ARKANSAS1028
LAKE SUPERIOR34
LAKE ST CLAIR32