How do I write a Kusto query that uses a regex to filter on a where clause

Viewed 15931

In Azure Log Analytics I'm trying to use Kusto to query requests with a where condition that uses a regex. The query I'm trying is

requests
| where customDimensions.["API Name"] matches regex "\w*-v\d*"

but this returns a syntax error. The example given in the documentation here is limited but implies that this syntax should work. A simpler version of the above does work

requests
| where customDimensions.["API Name"] matches regex ".*-v.*"

What is the correct syntax for where <predicate> matches regex in Kusto?

1 Answers

If the regex contains backslashes then it must be passed as a verbatim string as explained here. The following syntax worked

requests
| where customDimensions.["API Name"] matches regex @'\w*-v\d*'
Related