You can use curly braces to control the number of occurrences. For example, this means 0 to 10:
/^[a-z]{0,10}$/
The options are:
- {3} Exactly 3 occurrences;
- {6,} At least 6 occurrences;
- {,4} At most 4 occurrences;
- {2,5} 2 to 5 occurrences.
See the regular expression reference.
Your expression had a + after the closing curly brace, hence the error.