Can you please help me to achieve the below scenario using terraform? I need to prefix every special character in a string value with //.
Example : mysplchr="test O'riel*abc" this has to be changed as "test O//'riel//*abc"
Thanks
Not sure what is the issue here, but you can write it directly or change the original string automatically if you want:
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")
}
the outcome is:
test1 = test O//'riel//*abc
test2 = test O//'riel//*abc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With