Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
Removes trailing match of the specified regular expression.
Syntax
trim_end(regex, source)
Learn more about syntax conventions.
Parameters
| Name | Type | Required | Description | 
|---|---|---|---|
| regex | string | ✔️ | The string or regular expression to be trimmed from the end of source. | 
| source | string | ✔️ | The source string from which to trim regex. | 
Returns
source after trimming matches of regex found in the end of source.
Examples
The following statement trims substring from the end of string_to_trim.
let string_to_trim = @"bing.com";
let substring = ".com";
print string_to_trim = string_to_trim,trimmed_string = trim_end(substring,string_to_trim)
Output
| string_to_trim | trimmed_string | 
|---|---|
| bing.com | bing | 
Trim non-alphanumeric characters
The following example trims all non-word characters from the end of the string.
print str = strcat("-  ","Te st",x,@"// $")
| extend trimmed_str = trim_end(@"[^\w]+",str)
Output
| str | trimmed_str | 
|---|---|
| - Te st1// $ | - Te st1 | 
| - Te st2// $ | - Te st2 | 
| - Te st3// $ | - Te st3 | 
| - Te st4// $ | - Te st4 | 
| - Te st5// $ | - Te st5 | 
Trim whitespace
The following example trims all spaces from the end of the string.
let string_to_trim = @"    Hello, world!    ";
let substring = @"\s+";
print
    string_to_trim = string_to_trim,
    trimmed_end = trim_end(substring, string_to_trim)
Output
| string_to_trim | trimmed_end | 
|---|---|
| Hello, world! | Hello, world! |