How can I remove [" and "] in KQL from the below column values?
["xyz@test.com"]
["abc@test.com"]
["123@test.com"]
Thanks
How can I remove [" and "] in KQL from the below column values?
["xyz@test.com"]
["abc@test.com"]
["123@test.com"]
Thanks
I guess you would also like to remove the double quotes.
datatable(col:string)
[
'["xyz@test.com"]'
,'["abc@test.com"]'
,'["123@test.com"]'
]
| 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 |
|---|---|---|---|---|
| ["xyz@test.com"] | xyz@test.com | xyz@test.com | xyz@test.com | xyz@test.com |
| ["abc@test.com"] | abc@test.com | abc@test.com | abc@test.com | abc@test.com |
| ["123@test.com"] | 123@test.com | 123@test.com | 123@test.com | 123@test.com |
Fiddle