In Swift, can you split a string by another string, not just a character?

前端 未结 2 1848
情书的邮戳
情书的邮戳 2020-12-11 14:54

In Swift, it\'s easy to split a string on a character and return the result in an array. What I\'m wondering is if you can split a string by another string instead of just

2条回答
  •  庸人自扰
    2020-12-11 15:25

    import Foundation
    
    let inputString = "This123Is123A123Test"
    let splits = inputString.components(separatedBy: "123")
    

提交回复
热议问题