Created
June 15, 2018 17:25
-
-
Save onmyway133/3d3577ecd20d3decc9bce2c312450e69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func parseNumber(text: String) -> Int? { | |
let acceptedLetters = Array(0...9).map(String.init) + ["-"] | |
let characters = text | |
.replacingOccurrences(of: "\n", with: "") | |
.replacingOccurrences(of: "o", with: "0") | |
.filter({ acceptedLetters.contains(String($0)) }) | |
return Int(String(characters)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment