2024-09-08 00:26:50
public extension NSString {
func split(splitStr:NSString)->[NSString] {
let scanner = Scanner(string: self as String)
var arr:[NSString] = []
while (scanner.isAtEnd == false){
var subStr:NSString? = ""
scanner.scanUpTo(splitStr as String, into: &subStr)
arr.append(subStr!)
}
return arr
}
}
测试效果如图