Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 将javascript正则表达式转换为swift nsregularexpression_Regex_Swift_Nsregularexpression - Fatal编程技术网

Regex 将javascript正则表达式转换为swift nsregularexpression

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: "

我是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: "-")
                .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)