Regex 将javascript正则表达式转换为swift nsregularexpression
我是swift编程新手 我在javascript中有一个有效的正则表达式,我在swift中需要相同的功能Regex 将javascript正则表达式转换为swift nsregularexpression,regex,swift,nsregularexpression,Regex,Swift,Nsregularexpression,我是swift编程新手 我在javascript中有一个有效的正则表达式,我在swift中需要相同的功能 str.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, ''); 谢谢Swift 2.3: Swift 3: 非常感谢,这真的是我的1d let str = "A+B/C====" let result = str.stringByReplacingOccurrencesOfString("+", withString: "
str.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, '');
谢谢Swift 2.3:
Swift 3:
非常感谢,这真的是我的1d
let str = "A+B/C===="
let result = str.stringByReplacingOccurrencesOfString("+", withString: "-")
.stringByReplacingOccurrencesOfString("/", withString: "_")
.stringByReplacingOccurrencesOfString("\\=+$", withString: "", options: .RegularExpressionSearch)
print(str)
print(result)
let str = "A+B/C===="
let result = str.replacingOccurrences(of: "+", with: "-")
.replacingOccurrences(of: "/", with: "_")
.replacingOccurrences(of: "\\=+$", with: "", options: .regularExpressionSearch)
print(str)
print(result)