Replacing Multiple Different Occurences with Multiple Different Replacements - Swift4.2

后端 未结 1 1650
情书的邮戳
情书的邮戳 2021-01-26 20:09

Trying to find the exact format for doing this.

I have a textField user input,

I want to take that input and find multiple occurrences and replace each unique occu

相关标签:
1条回答
  • 2021-01-26 20:59

    I am still not sure if this is exactly what you are asking but if I understood correctly you can zip your collections and iterate the resulting tuples:

    var result = "example"
    zip(["e", "x", "a", "m", "p", "l", "e"],["1", "3", "2", "8", "5", "7"]).forEach {
        result = result.replacingOccurrences(of: $0, with: $1, options: .literal)
    }
    result  // 1328571
    
    0 讨论(0)
提交回复
热议问题