1、判断是否数字
/// 判断是否是数字////// - Parameter string: <#string description#>/// - Returns: <#return value description#>class func isPurnInt(string: String) -> Bool {let scan: Scanner = Scanner(string: string)var val:Int = 0return scan.scanInt(&val) && scan.isAtEnd}
2、提取字符串里的数字
/// 从字符串中提取数字class func getIntFromString(str:String) -> String {let scanner = Scanner(string: str)scanner.scanUpToCharacters(from: CharacterSet.decimalDigits, into: nil)var number :Int = 0scanner.scanInt(&number)print(number)return String(number)}