Code Snippet: Print All Integers in a String

From Coder Merlin
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

Print All Integers in a String[edit]

var line : String?
repeat {
    line = readLine()
    if let text = line {
        for character in text {
            if ("0" ... "9").contains(character) {
                print(character)
            }
        }
    }
} while line != nil