helm-用下划线替换特殊字符

问题描述 投票:0回答:1

k8s和头盔的新手。

[尝试使用{{ .Release.Name }}声明部署中的字段,该字段不得包含字母(大写+小写),数字和_以外的字符。

排除的字符应替换为_,例如:feature/my-feature-1130

应替换为:feature_my_feature_1130

有人可以帮我创建一个这样的领域吗?

非常感谢!

regex kubernetes-helm sprig-template-functions
1个回答
0
投票

您在寻找这个

 String s = "feature/my-feature-1130";
          s = s.replaceAll("\\W","_");
          System.out.println(s);

输出 feature_my_feature_1130抱歉,我使用的不是哪种编程语言,此regex可在java中使用,但您可以尝试使用它,是否适合您]

© www.soinside.com 2019 - 2024. All rights reserved.