Replace string multiple characters in Swift
Forums:
var str = "1-/[=2=/]-3"
let separators = ["/", "=", "[", "]"]
let arStr = str.characters.split { separators.contains(String($0)) }.map { String($0) }
str = arStr.joinWithSeparator("")
//str is "1-2-3"
- Log in to post comments