Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Special Characters in KQL

Tags:

kql

How can I remove [" and "] in KQL from the below column values?

["[email protected]"]  
["[email protected]"]  
["[email protected]"]

Thanks

like image 756
Gary Avatar asked Dec 05 '25 17:12

Gary


1 Answers

I guess you would also like to remove the double quotes.

datatable(col:string)
[
     '["[email protected]"]'  
    ,'["[email protected]"]' 
    ,'["[email protected]"]'
]
| extend option_1 = trim(@'^\["|"]$', col)          // Trim opening [" and closing "]
| extend option_2 = trim(@'[[\]"]+', col)           // Trim sequences of the characters [, ] and "
| extend option_3 = extract(@'^\["(.*)"]$', 1, col) // Extract the expression between the opening [" and closing "]
| extend option_4 = tostring(todynamic(col)[0])     // Convert to json (resulting in json array) and retrieve the 1st element
col option_1 option_2 option_3 option_4
["[email protected]"] [email protected] [email protected] [email protected] [email protected]
["[email protected]"] [email protected] [email protected] [email protected] [email protected]
["[email protected]"] [email protected] [email protected] [email protected] [email protected]

Fiddle

like image 92
David דודו Markovitz Avatar answered Dec 12 '25 13:12

David דודו Markovitz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!