I need help with regular expression. I need a expression which allows only alphabets with space for ex. college name.
I am using :
var regex = /^[a-
This will work for not allowing spaces at beginning and accepts characters, numbers, and special characters
/(^\w+)\s?/
This will allow space between the characters and not allow numbers or special characters. It will also not allow the space at the start and end.
[a-zA-Z][a-zA-Z ]+[a-zA-Z]$
Regular expression starting with lower case or upper case alphabets but not with space and can have space in between the alphabets is following.
/^[a-zA-Z][a-zA-Z ]*$/
This worked for me
/[^a-zA-Z, ]/
Just add the space to the [ ] :
var regex = /^[a-zA-Z ]*$/;