swift 4 string trim whitespace code example
Example: how to get rid of excess space in swift
let str = " Taylor Swift "
let trimmed = str.trimmingCharacters(in: .whitespacesAndNewlines) // prints "Taylor Swift"
let str = " Taylor Swift "
let trimmed = str.trimmingCharacters(in: .whitespacesAndNewlines) // prints "Taylor Swift"