用swift判断string是否包含字母
/* string是要判断的那个String */
let characterset = CharacterSet(charactersIn: string)
let stringContain = string.rangeOfCharacter(from: characterset)
if stringContain != nil{
/* 包含 */
}
/* 或 */
let stringContain1 = string.rangeOfCharacter(from: NSCharacterSet.letters)
if stringContain1 != nil{
/* 包含 */
}
Hunter药药

浙公网安备 33010602011771号