0

I'm trying to replace all the dot characters in a helm template string with \., like so:

{{- regexReplaceAllLiteral "\." "https://endpoint.index.up" "\\\." -}}

I want this to output - https://endpoint\.index\.up

This is giving me a parse error. I've tried a bunch of different combinations but nothing is replacing the dot characters. Any help appreciated!

David Maze
  • 130,717
  • 29
  • 175
  • 215
covfefe
  • 2,485
  • 8
  • 47
  • 77

1 Answers1

0

If you're just trying to replace a fixed string, replace will be easier to use. (This is one of the Sprig string functions so it will work with other tools that also embed the Sprig template extensions.)

{{- "https://endpoint.index.up" | replace "." "\\." -}}

It doesn't look like backslash is treated specially in the replacement string argument to regexReplaceAllLiteral so it should work so long as the replacement string argument is backslash dot; inside the double-quoted string syntax you need to double the backslash but you do not need to escape the period, so again "\\." and not "\\\.".

David Maze
  • 130,717
  • 29
  • 175
  • 215