更新时间:2022-05-14 08:48:03
您需要使用另一个反斜杠来转义反斜杠.所以如果你想用 "\:"
替换 ":"
你需要用 "\\:"
替换.
You need to escape backslashes with another backslash. So if you want to replace ":"
with "\:"
you need to replace with "\\:"
.
let backslashString = string.replacingOccurrences(of: ":", with: "\\:")