删除指定正则表达式的前导匹配项。Removes leading match of the specified regular expression.


trim_start(regex, text)trim_start(regex, text)


  • regex:要从 text 的开头修剪的字符串或正则表达式regex: String or regular expression to be trimmed from the beginning of text.
  • text:一个字符串。text: A string.


修剪 text 开头的 regex 匹配项后的 text。text after trimming match of regex found in the beginning of text.


以下语句从 string_to_trim 的开头修剪 substring:Statement bellow trims substring from the start of string_to_trim:

let string_to_trim = @"";
let substring = "https://";
print string_to_trim = string_to_trim,trimmed_string = trim_start(substring,string_to_trim)
string_to_trimstring_to_trim trimmed_stringtrimmed_string

下一条语句从字符串的开头修剪所有非单词字符:Next statement trims all non-word characters from the beginning of the string:

range x from 1 to 5 step 1
| project str = strcat("-  ","Te st",x,@"// $")
| extend trimmed_str = trim_start(@"[^\w]+",str)
strstr trimmed_strtrimmed_str
- Te st1// $- Te st1// $ Te st1// $Te st1// $
- Te st2// $- Te st2// $ Te st2// $Te st2// $
- Te st3// $- Te st3// $ Te st3// $Te st3// $
- Te st4// $- Te st4// $ Te st4// $Te st4// $
- Te st5// $- Te st5// $ Te st5// $Te st5// $