How can I split string with separator of another string or multiple characters?
let s = "#! it #! happens #! sometimes"
s.split(separator: "#!")
Thanks
How can I split string with separator of another string or multiple characters?
let s = "#! it #! happens #! sometimes"
s.split(separator: "#!")
Thanks
There's a method in Foundation that does what you want
import Foundation
let s = "#! it #! happens #! sometimes"
print(s.components(separatedBy: "#!")) // ["", " it ", " happens ", " sometimes"]
Thanks.
Now, I can find it under StringProtocol