You can use the following regular expression: ^[a-zA-Z -]+$ .
^ matches the beginning of the line, which prevents it from aligning the middle of the line 123abc . $ matches the end of a line similarly, preventing it from matching the middle of abc123 .
The brackets correspond to each character within them; az means every character between a and z . To match the character itself - place it at the end. ( [19-] matches a 1 , a 9 or - ; [1-9] matches each character between 1 and 9 and does not match - ).
+ reports that it corresponds to one or more things in front of him. You can replace + with * , which means 0 or more if you also want to match an empty string.
For more information see here .
SLaks source share