Skip to content

Instantly share code, notes, and snippets.

@onmyway133
Created June 15, 2018 17:25
Show Gist options
  • Save onmyway133/3d3577ecd20d3decc9bce2c312450e69 to your computer and use it in GitHub Desktop.
Save onmyway133/3d3577ecd20d3decc9bce2c312450e69 to your computer and use it in GitHub Desktop.
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