Does anyone know how to modify my current RegEx expression to disallow 4 or more consecutive letters of the same kind? Here is what I have so far:
(^[A-Za-z]{1})([A-Za-z\-\'\s]{0,})([A-Za-z]{1}$)
It fulfills almost all of my criteria, except for one:
- Any alphabetic character
- Single spaces, but not as the first or last character
- Hyphens, but not as the first or last character
- Single quotes, but not as the first or last character
- No more than 3 consecutive characters of the same kind, regardless of case
- Must be at least 2 characters long, when present
Here are some examples:
James - valid
Sarah Jayne - valid
Michellle - valid
O'Brian - valid
Holly-Rose - valid
Eeeeric - invalid
Jo--anne - invalid