Regex min/max length combined with other expressions
Posted: Thu Oct 01, 2015 2:17 am
I'm working on a Regex which has the following limitations;
1. No punctuations but a dash
2. No numbers only characters
3. First letter should be uppercase
4. Minimal 3 characters
5. Maximal 12 characters
Except for nr. 4/5 this has the required result.
^[A-Z][a-z]+(-[A-Z][a-z]+)?$
For the last part I've tried the following but it's not working correctly. Who can help me figure this out?
^([A-Z][a-z]+(-[A-Z][a-z]+)?){2,12}$
See also
https://www.debuggex.com/r/JIyOwvdYdO0WgrwI
1. No punctuations but a dash
2. No numbers only characters
3. First letter should be uppercase
4. Minimal 3 characters
5. Maximal 12 characters
Except for nr. 4/5 this has the required result.
^[A-Z][a-z]+(-[A-Z][a-z]+)?$
For the last part I've tried the following but it's not working correctly. Who can help me figure this out?
^([A-Z][a-z]+(-[A-Z][a-z]+)?){2,12}$
See also
https://www.debuggex.com/r/JIyOwvdYdO0WgrwI