📜  在 swift 代码示例中替换字符

📅  最后修改于: 2022-03-11 15:01:01.304000             🧑  作者: Mango

代码示例1
extension String {
    func withReplacedCharacters(_ oldChar: String, by newChar: String) -> String {
        let newStr = self.replacingOccurrences(of: oldChar, with: newChar, options: .literal, range: nil)
        return newStr
    }
}