Swift 判断字符串中是否有汉字

var str = "嗷嗷朴素,1234"

func isIncludeChineseIn(string: String) -> Bool {
    
    for (_, value) in string.characters.enumerated() {

        if ("\u{4E00}" <= value  && value <= "\u{9FA5}") {
            return true
        }
    }
    
    return false
}

isIncludeChineseIn(string: str) // true

你可能感兴趣的:(Swift 判断字符串中是否有汉字)