Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. let smallLetterRegEx = "[a-z]"
  2. let capitalLetterRegEx = "[A-Z]"
  3. let smallLetterText = NSPredicate(format:"SELF MATCHES %@", smallLetterRegEx)
  4. if smallLetterText.evaluate(with: password) {
  5.  
  6. let str = textViewStringArray.joined(separator: "n")
  7. let lowerCaseString = "• At least 1 Lower case letter"
  8. let range = (str as NSString).range(of: lowerCaseString)
  9. let attribute = NSMutableAttributedString.init(string: str)
  10. attribute.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.darkGreen, range: range)
  11. DispatchQueue.main.async {
  12. self.textView.attributedText = attribute
  13. }
  14.  
  15. self.view.setNeedsDisplay()
  16. //label.attributedText = str
  17. }
  18.  
  19.  
  20. let capitalLetter = NSPredicate(format:"SELF MATCHES %@", capitalLetterRegEx)
  21. if capitalLetter.evaluate(with: password) {
  22. let str = textViewStringArray.joined(separator: "n")
  23. let lowerCaseString = "• At least 1 Upper case letter"
  24. let range = (str as NSString).range(of: lowerCaseString)
  25.  
  26. DispatchQueue.main.async {
  27. let attribute = NSMutableAttributedString.init(string: str)
  28. attribute.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.darkGreen, range: range)
  29. self.textView.attributedText = attribute
  30. }
  31.  
  32.  
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement