}
//只能为小写
func onlyInputLowercaseLetter(_ string: String) -> Bool {//只能为大写
func onlyInputACapital(_ string: String) -> Bool {}
//允许大小写或数字(不限字数)
func inputLettersOrNumbers(_ string: String) -> Bool {}
//允许大小写或数字(限字数)
func inputNumberOrLetters(_ name: String) -> Bool {
var userNameRegex = "^[A-Za-z0-9]{6,20}+$"
var userNamePredicate = NSPredicate(format: "SELF MATCHES %@", userNameRegex)
var inputString = userNamePredicate.evaluate(withObject: name)
return inputString
}
//允许汉字,大小写或数字(限字数)
func inputChineseOrLettersNumberslimit(_ string: String) -> Bool {
var regex = "[\u{4e00}-\u{9fa5}]+[A-Za-z0-9]{6,20}+$"
var predicate = NSPredicate(format: "SELF MATCHES %@", regex)
var inputString = predicate.evaluate(withObject: string)
return inputString
}
//允许汉字或数字(不限字数)
func inputChineseOrNumbers(_ string: String) -> Bool {
var regex = "[\u{4e00}-\u{9fa5}]+[0-9]*"
var predicate = NSPredicate(format: "SELF MATCHES %@", regex)
var inputString = predicate.evaluate(withObject: string)
return inputString
}
//允许汉字或数字(限字数)
func inputChineseOrNumbersLimit(_ string: String) -> Bool {
var regex = "[\u{4e00}-\u{9fa5}][0-9]{6,20}+$"
var predicate = NSPredicate(format: "SELF MATCHES %@", regex)
var inputString = predicate.evaluate(withObject: string)
return inputString
}
//允许汉字,大小写或数字(不限字数)
}
//允许汉字,大小写或数字(限字数)
func inputChineseOrLettersNumberslimit(_ string: String) -> Bool {
var regex = "[\u{4e00}-\u{9fa5}]+[A-Za-z0-9]{6,20}+$"
var predicate = NSPredicate(format: "SELF MATCHES %@", regex)
var inputString = predicate.evaluate(withObject: string)
return inputString
}