Regular expression in javascript to match only letters or spaces
1 answer
What you want is a minimum of 4 characters - you are trying to make it work expecting at least 5 characters because of the optional character [^\s]
at the end. What's more, [^\s]
will actually match any character that is not a space - I'd bet you want to restrict this to just letters?
Try this instead:
^[a-z\s?]{3,119}[a-z]$
+1
source to share