I am looking for a way to replace characters in a Swift String.
String
Example: \"This is my string\"
I would like to replace \" \" with \"+\" to get \
Swift 4:
let abc = "Hello world" let result = abc.replacingOccurrences(of: " ", with: "_", options: NSString.CompareOptions.literal, range:nil) print(result :\(result))
Output:
result : Hello_world