Another Bronze Challenge solution

I used NSCharacterSet to eliminate everything except numbers. It’s a little clunky :slight_smile:

let existingTextHasDecimalSeparator = textField.text?.range(of: ".")
let replacementTextHasDecimalSeparator = string.range(of: ".")
let replacementTextHasValidNums = string.rangeOfCharacter(from: NSCharacterSet.decimalDigits)

    if (existingTextHasDecimalSeparator != nil && replacementTextHasDecimalSeparator != nil) || replacementTextHasValidNums == nil {
        return false
    } else {
        return true
    }