I want to cut several substrings out of a string, which are always between two whitespace, in order to use them further. but I get an extra sign (" ") at the end ... What am I doing wrong? Who can help?
let text = "123045 7890 842 abcde fghij"
var index4Blank = text.index(of: " ") // first 'blank'
index4Blank?.encodedOffset
// Find NEXT/last occurance of " "
if let rangeOfBlank = text.range(of: " ", options: .backwards) {
// Get the characters between first 'blank' and next 'blank'
let suffix = text[index4Blank!..<rangeOfBlank.upperBound] // "7890 "
print(suffix)
}
what I want: "123045" and "7890" and "842" and "abcde" and "fghij" ((Sorry for the question, but I'm really a beginner in Swift))