I'm using following regex to validate name:
^[a-zA-Z]{1}[a-zA-Z.' ]{1,20}$
Single quote is mentioned in the second range. However, when I validate a string against this regex, single quote (') invalidates the match. Here's my code:
let nameRegEx = "^[a-zA-Z]{1}[a-zA-Z.' ]{1,21}$"
let nameTest = NSPredicate(format:"SELF MATCHES %@", nameRegEx)
let isNameValid = nameTest.evaluate(with: name)
I've tried \' but no use.