I'm using the following regex to validate the name:
> ^[a-zA-Z]{1}[a-zA-Z.' ]{1,20}$
The single quote is mentioned in the second range. However, when I validate a string against this regex, the 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.