What is a regular expression to allow letters only, with no spaces or numbers, with a length of 20 characters?
Some examples of acceptable usernames:
ask1kew
supacool
sec1entertainment
ThatPerson1
Alexking
Some examples of unacceptable usernames:
No_problem1
a_a_sidkd
Thenamethatismorethen20characterslong
This should work if you’re limiting yourself to ASCII:
That will also match an empty string though so you might want to add a lower limit (5 in this example):
If you wanted to be adventurous and allow non-ASCII letters and you’re using Ruby 1.9 then you could use this: