如何将replacementOccurrences与regex一起使用并仅替换第一次出现?
例
var str = "= 1 = 2 = 3"
str = str.replacingOccurrences(of: "(\\d+)", with: "\\\\$1", options: .regularExpression)
// prints: = \\1 = \\2 = \\3
// should print: = \\1 = 2 = 3
Run Code Online (Sandbox Code Playgroud)