[英]Error with swift regex using swiftvalidator?
I'm using the swiftValdator framework for iOS development.我正在使用 swiftValdator 框架进行 iOS 开发。 I created a custom validator class with a regex.我用正则表达式创建了一个自定义验证器类。
The error is:错误是:
'NSInternalInconsistencyException', reason: 'Can't do regex matching, reason: Can't open pattern U_REGEX_MISSING_CLOSE_BRACKET (string lol, pattern ^(?=.*[az])(?=.*[AZ])(?=.*[0-9])(?=.*[,.:=+-_|)(%$#@!£/?';&"\\])[A-Za-z0-9,.:=+-_|)(%$#@!]£/?';&"\\]{8,32}, case 0, canon 0)'
This is my code:这是我的代码:
import Foundation
import SwiftValidator
class CustomPasswordRule: RegexRule {
//^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[,.:=+\-_|)(%$#@!£/?`;&"\\])[A-Za-z\d,.:=+\-_|)(%$#@!£/?`;&"\\]{8,32}
static let regex = "^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[,.:=+-_|)(%$#@!£/?';&\"\\])[A-Za-z0-9,.:=+-_|)(%$#@!]£/?';&\"\\]{8,32}"
convenience init(message: String = "Not a valid Password") {
self.init(regex: CustomPasswordRule.regex,message: message)
}
}
Can anyone help me with the error?谁能帮我解决这个错误? These are the conditions:这些是条件:
"" 中的正则表达式没有正确转换,试试这个:
static let regex = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[,.:=+\\-_|)(%$#@!£/?`;&\"\\\\])[A-Za-z\\d,.:=+\\-_|)(%$#@!£/?`;&\"\\\\]{8,32}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.