I'm trying to make a nickname validator. Here are the rules I want:
- Total character count must be between 3 and 15
- There can be two non-consecutive spaces
- Only letters (a-z) are allowed
- Each word separated by a space can begin with an uppercase letter, the rest of the word must be lowercase
- At least one of the words must have 3 or more characters
This is what I currently have which checks the four first rules, but I have no idea how to check the last rule.
^(?=.{3,15}$)(\b[A-Z]?[a-z]* ?\b){1,3}$
Should match:
- Yaw
- yaw
- James Bond
- Monkey D Luffy
- List item
Shouldn't match:
- YaW
Two spaces
(with two consecutive space characters)- No no no
- JamesBond