我想创建正则表达式,我可以检查字符串是否包含任何大写或小写字母,并且还包含应该返回 true 的数字。
如果我可以限制字符数示例:仅限 64 个字符
示例:
Apple = True
aPPle = True
App1e = True
@apple = true
!^%$# = false (because it does not contains any letters or digits.)
我尝试过的正则表达式如下,但它不起作用:
let localRegex = "[A-Za-z0-9]{1,64}\\."
let input = "Your_Input_String_Here"
let regex = "^(?=.*[a-zA-Z])(?=.*\\d).*$"
if let range = input.range(of: regex, options: .regularExpression) {
print("True")
} else {
print("False")
}