ljh
(ljh)
1
How can I split string with separator of another string or multiple characters?
let s = "#! it #! happens #! sometimes"
s.split(separator: "#!")
Thanks
cukr
2
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"]
1 Like
ljh
(ljh)
3
Thanks.
Now, I can find it under StringProtocol