Извините, я думаю, что это немного сложный метод, но он должен работать:
let address = "Aipda Karel Sasuit Tubun No.106B, RT.2/RW.1, Ps. Baru, Karawaci, Kota Tangerang, Banten 15112, Indonesia"
let keyword = "Indonesia"
let components: [String] = address.split(separator: " ").map({ String($0).replacingOccurrences(of: ",", with: "") })
var postCode = components.first ?? ""
for comp in components {
if comp == keyword {
break
}
postCode = comp
}
print(postCode)