trim_end()
Removes trailing match of the specified regular expression.
Syntax
trim_end(
regex,
source)
Arguments
- regex: String or regular expression to be trimmed from the end of source.
- source: A string.
Returns
source after trimming matches of regex found in the end of source.
Example
Statement bellow trims substring from the end of string_to_trim:
let string_to_trim = @"ibm.com";
let substring = ".com";
print string_to_trim = string_to_trim,trimmed_string = trim_end(substring,string_to_trim)
Returns
string_to_trim | trimmed_string |
---|---|
ibm.com | ibm |
Next statement trims all non-word characters from the end of the string:
print str = strcat("- ","Te st",x,@"// $")
| extend trimmed_str = trim_end(@"[^\w]+",str)
Returns
str | trimmed_str |
---|---|
|
|
|
|
|
|
|
|
|
|