Abdennour TOUMI
Abdennour TOUMI

Reputation: 93203

Helm regex match from the beginning until the last occurance of a character

Struggling with Helm to match the word from its beginning to the last occurance of -.

I tried {{- printf "%s" .Release.Name | regexFind "[^-]*$" -}}, but it prints from the last occurrance to the end of the word.

Expected

input : hello-world-here => output: hello-world

input : hello-world-here-and-there => output : hello-world-here-and

Upvotes: 1

Views: 7191

Answers (1)

Abdennour TOUMI
Abdennour TOUMI

Reputation: 93203

Big thanks to @Wiktor Stribiżew for his hints.

After a lot of investigation, I realized that the Regex is correct, but the signature of function is amazing :

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

and NOT :

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

Upvotes: 5

Related Questions