Read John Sundell’s String parsing in Swift. I haven’t used Scanner from Objective-C for ages! Lazy implementation of tokenizer worth a bookmark.