isChinese(str: "测")
func isChinese(str: String) -> Bool{
let match: String = "(^[\\u4e00-\\u9fa5]+$)"
let predicate = NSPredicate(format: "SELF matches %@", match)
return predicate.evaluate(with: str)
}
isChinese(str: "测")
func isChinese(str: String) -> Bool{
let match: String = "(^[\\u4e00-\\u9fa5]+$)"
let predicate = NSPredicate(format: "SELF matches %@", match)
return predicate.evaluate(with: str)
}
本文标题:Swift5-swift 检测字符串是否是中文
本文链接:https://www.haomeiwen.com/subject/ymkdihtx.html
网友评论