相关疑难解决方法(0)

如何替换Swift中的第一次出现?

如何将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)

regex swift

6
推荐指数
1
解决办法
928
查看次数

标签 统计

regex ×1

swift ×1