I have a string and there are multiple substrings that will need to be replaced in it.
The string:
string1 = "I want to fly tomorrow"
I will need to take whatever that needs to replaced from a map.
The map:
map1 = {
"I": "we"
"want": "do not want"
"tomorrow": "today"
}
So the keys in the map1 map are what need to be replaced in the string1 string and the values should be the new values in the string.
The result should look something like this:
we do not want to fly today
I have been thinking of a solution but I am not even close.
I tried this:
try = [for replacement in keys(local.map1): replace(local.string1, replacement, local.map1[replacement])]
but this returns a list of strings that each have only one value replaced.
NOTE: string1 and map1 are just examples and they could have any other values so I am looking for a general solution please :)