Regular Expression To Match Only Alphabets And Spaces

Category: Strings

Regular expressions are one of the most powerful tools in a programmer’s arsenal.

If you have ever attempted to create your own regular expression to match only alphabets and spaces, you might find this article useful.

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

Matches:

  • ABC D
  • ABCD
  • ABC d
  •  ABC

Non-matches:

See Also:

Rate This Regex
Sending
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.