Trimming Leading and Trailing spces from String in Swift Posted on 23/11/202123/11/2021 by Phillip Jubb let trimmedString = string.trimmingCharacters(in: .whitespaces) This works in Swift 3+ Found at: SO