Strings In Depth14 / 18
Up next

Trim whitespace

import Foundation

let raw = "   padded   "
// strip leading and trailing whitespace
let clean = raw.trimmingCharacters(in: .whitespaces)
print("[\(clean)]")
What you're solving

trimmingCharacters(in:)