0

I'm trying to pull out a file name and it's extension when it's part of a file path, here's the regex I'm using:

([^\\]*\.\w+)

Here's an example file path I've tested using regex101:

c:\\users\\u10061279\\appdata\\local\\temp\\2cert_desktop.xml

 

This works fine when I'm testing using regex101 etc. but when I try and put this into a query as per the below: ExtractQuery

The syntax looks messed up and when I hover over the query it says it's missing '"' QueryError

I'm unsure how I can get this to work, I've been playing about with it for a while and can't get the errors to clear. Thanks in advance!

Alexander Sloutsky
  • 2,827
  • 8
  • 13
user13798673
  • 1
  • 1
  • 1
  • 1

1 Answers1

1

You can use '@' prefix to a string literal (similar to .NET).

More on Kusto string literals: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/scalar-data-types/string

print m="c:\\users\\u10061279\\appdata\\local\\temp\\2cert_desktop.xml"
| project extract(@"([^\\]*\.\w+)", 1, m)
Alexander Sloutsky
  • 2,827
  • 8
  • 13