Dates, Formatting, and Text
Split and Join Text
Splitting text creates pieces that can be joined in a new format.
Recombine words
split_join_text.swift
let separator =
let text = "swift trace replay"
let words = text.split(separator: " ")
let message = words.joined(separator: separator)
print(message)
let separator =
let text = "swift trace replay"
let words = text.split(separator: " ")
let message = words.joined(separator: separator)
print(message)
let separator =
let text = "swift trace replay"
let words = text.split(separator: " ")
let message = words.joined(separator: separator)
print(message)
split join
`split` separates a string into parts, and `joined` combines those parts with a chosen separator.