RosettaCodeData/Task/Tokenize-a-string/Swift/tokenize-a-string-1.swift

6 lines
198 B
Swift
Raw Permalink Normal View History

2016-12-05 23:44:36 +01:00
let text = "Hello,How,Are,You,Today"
2017-09-23 10:01:46 +02:00
let tokens = text.components(separatedBy: ",") // for single or multi-character separator
2016-12-05 23:44:36 +01:00
print(tokens)
2017-09-23 10:01:46 +02:00
let result = tokens.joined(separator: ".")
2016-12-05 23:44:36 +01:00
print(result)