问题描述
您能帮助我使用terraform实现以下方案吗? 我需要在字符串值中的每个特殊字符前加上//.
示例:mysplchr="test O'riel*abc"
必须更改为"test O//'riel//*abc"
谢谢
解决方法
不确定此处的问题是什么,但是您可以直接编写它,也可以根据需要自动更改原始字符串:
variable "mysplchr" {
default = "test O//'riel//*abc"
}
output "test1" {
value = var.mysplchr
}
# or to do it automatically for
# the original string
output "test2" {
value = replace("test O'riel*abc","/(['\\*])/","//$1")
}
结果是:
test1 = test O//'riel//*abc
test2 = test O//'riel//*abc