CharacterSet
をうまく使うといい感じにできる.
例えばカンマとピリオドを含んだ文をそれらで分割する場合は以下のようにする.
let str = "a,b,cde,fgh.ijk.lmn"
let list = str.components(separatedBy: CharacterSet(charactersIn: ",."))
Swift.print(list)
// -> ["a", "b", "cde", "fgh", "ijk", "lmn"]
Go to list of users who liked
More than 5 years have passed since last update.
CharacterSet
をうまく使うといい感じにできる.
例えばカンマとピリオドを含んだ文をそれらで分割する場合は以下のようにする.
let str = "a,b,cde,fgh.ijk.lmn"
let list = str.components(separatedBy: CharacterSet(charactersIn: ",."))
Swift.print(list)
// -> ["a", "b", "cde", "fgh", "ijk", "lmn"]
Register as a new user and use Qiita more conveniently
Go to list of users who liked