Only the last iteration of thing persists because it is recreated on each iteration of i. Change the initialisation of thing to be str, i.e. to "SOME SEARCH TEXT" and the reference to str.map to be thing.map and it will work:
let str = "SOME SEARCH TEXT"
var thing = str
let letters = ["A","E","S"]
let replacements = ["a", "e", "s"]
letters.enumerated().forEach { (i,r) in
thing = String(thing.map {$0 == Character(String(r)) ? Character(String(replacements[i])) : $0});
print(thing)
}
If it's OK to have str mutate, then you can change str to a var and then use this code:
var str = "SOME SEARCH TEXT"
let letters = ["A","E","S"]
let replacements = ["a", "e", "s"]
letters.enumerated().forEach { (i,r) in
str = String(str.map {$0 == Character(String(r)) ? Character(String(replacements[i])) : $0});
print(str)
}
Best wishes and regards, Michaela