Javascript regex for alphabetic characters and spaces?

You can use this to match a sequence of a-z, A-Z and spaces:

/[a-zA-Z ]+/

If you're trying to see if a string consists entirely of a-z, A-Z and spaces, then you can use this:

/^[a-zA-Z ]+$/

Demo and tester here: http://jsfiddle.net/jfriend00/mQhga/.

For other regex symbols, there are tons of references on the internet. This is the one I have bookmarked and look at regularly: http://www.javascriptkit.com/javatutors/redev2.shtml.

And, you can practice in an online tool here: http://www.regular-expressions.info/javascriptexample.html.


/^[A-Za-z ]+$/ or /^[A-Za-z\s]+$/

More good stuff here:
http://www.regular-expressions.info/javascript.html


or just /\w+$/ if you also want 0-9 and underscores (\w stands for "word character", usually [A-Za-z0-9_]). But your recent edit indicates that you dont want 0-9, so use one of the first 2 above.