Regex trim help in Azure Data Explorer

AlonD 21 Reputation points Microsoft Employee


I have a Azure Data Explorer query that returns ID as part of it.
The part of the query is like that:

id = any_id,

Since I'm using this ID as a placeholder in an automation process, I nee to strip the ID from anything but numbers or letters.
Trying to do so with regex failed although I was working according to the documentation below:

The line in the query looks like that:
id = trim(@"[^\w]+",any_id),

Unfortunately the data still comes with characters that are not only letters or numbers.

Assistance will be greatly appreciated :)


Azure Data Explorer
Azure Data Explorer
An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.
487 questions
{count} votes

Accepted answer
  1. KranthiPakala-MSFT 46,427 Reputation points Microsoft Employee

    Hello @AlonD ,

    Thank you for clarifying the ask and sharing a sample.

    Please try replace_regex() function which should help achieve your requirement. Please refer to below sample.

    let str = "711ab733-6098-11c4_cbcc-e23562352354:public:nonprod:linux:linux_iaas:critical";  
    print trimmed_str = replace_regex(str, @"[^0-9A-Za-z]", "")  



    Hope this will help. Please let us know if any further queries.


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

0 additional answers

Sort by: Most helpful