从角色的开始到最后一次出现的 Helm 正则表达式匹配



努力与 Helm 匹配从开头到最后一次出现的-单词。

我尝试了{{- printf "%s" .Release.Name | regexFind "[^-]*$" -}},但它从最后一次出现到单词末尾打印。

预期

输入 : hello-world-here => 输出: hello-world

输入 : hello-world-here-and-there => 输出 : hello-world-here-and

非常感谢@Wiktor Stribiżew的提示。

经过大量调查,我意识到正则表达式是正确的,但是函数的签名是惊人的:

{{- regexReplaceAll "-[^-]*$" .Release.Name "" -}}

而不是 :

 {{- regexReplaceAll "-[^-]*$"  "" .Release.Name -}}

最新更新