If you're referring to this function then it trims using a regular expression, not a set of characters. The string com
would match and trim only the string value com
. Not the individual characters c
, o
and m
. If you want to strip characters then use character groups. Something like this perhaps trim_end("[com]", domain)
. That would trim the letters c
, o
and m
from the end of the string in any order. So .com
would become .
, .bom
would become .b
and xyzmoc
would become xyz
.
Why does trim_end("bom", "dotcom.com") return the original string, while trim_end("com", "dotcom.com") trims as expected?
Kooghan Williams
0
Reputation points
I'm working with trim_end()
in KQL (Azure Data Explorer) and noticed some confusing behavior when using different combinations of characters to trim a domain string.
Here’s a minimal repro:
let ExampleTable = datatable(domain: string)
[
"dotcom.com"
];
ExampleTable
| extend trimmed1 = trim_end("com", domain),
trimmed2 = trim_end("bom", domain),
trimmed3 = trim_end("moc", domain)
**Expected:** Since all three versions of the `trimChars` set contain the letters `c`, `o`, and `m`, I assumed they would all behave the same — trimming the `.com` suffix from `"dotcom.com"`.
**Actual:**
|domain|trimmed1|trimmed2|trimmed3|
| -------- | -------- | -------- | -------- |
|dotcom.com|dotcom.|dotcom.com|dotcom.|
|dotcom.com|dotcom.|dotcom.com|dotcom.|
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.
1 answer
Sort by: Most helpful
-
Michael Taylor 60,601 Reputation points
2025-06-16T15:04:48.6066667+00:00