从字符串中删除转义百分比的字符

Gaz*_*ini 0 ios swift

如何使用Swift从字符串中删除,而不是解码百分比转义字符.例如:

"hello%20there" 应该成为 "hellothere"

编辑:

我想替换字符串中的多个转义百分比字符.所以: "hello%20there%0Dperson" 应该成为 "hellothereperson"

Zha*_*Chn 6

let string = originalString.replacingOccurrences(of: "%[0-9a-fA-F]{2}", 
                                                 with: "",
                                                 options: .regularExpression, 
                                                 range: nil)
Run Code Online (Sandbox Code Playgroud)