Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let smallLetterRegEx = "[a-z]"
- let capitalLetterRegEx = "[A-Z]"
- let smallLetterText = NSPredicate(format:"SELF MATCHES %@", smallLetterRegEx)
- if smallLetterText.evaluate(with: password) {
- let str = textViewStringArray.joined(separator: "n")
- let lowerCaseString = "• At least 1 Lower case letter"
- let range = (str as NSString).range(of: lowerCaseString)
- let attribute = NSMutableAttributedString.init(string: str)
- attribute.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.darkGreen, range: range)
- DispatchQueue.main.async {
- self.textView.attributedText = attribute
- }
- self.view.setNeedsDisplay()
- //label.attributedText = str
- }
- let capitalLetter = NSPredicate(format:"SELF MATCHES %@", capitalLetterRegEx)
- if capitalLetter.evaluate(with: password) {
- let str = textViewStringArray.joined(separator: "n")
- let lowerCaseString = "• At least 1 Upper case letter"
- let range = (str as NSString).range(of: lowerCaseString)
- DispatchQueue.main.async {
- let attribute = NSMutableAttributedString.init(string: str)
- attribute.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.darkGreen, range: range)
- self.textView.attributedText = attribute
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement