Regular expression for [a-zA-Z]

I have a regular expression that matches only English letters, the character class [a-zA-Z] .

Is there any built-in regex for this? I mean something like \s or \w .

+1
source share
1 answer

You are requesting an abbreviated class for English letters.

If you use a POSIX-compatible regular expression , [:alpha:] is the "bracket expression" for the class [a-zA-Z] . It is also supported by PCRE (Perl, PHP, Ruby ...).

In Java, you can use \p{Alpha} .

B. NET , PCRE , Java , \p{L} more than just [a-zA-Z] because it can include all Unicode letters. However, it can be used to capture only letters.

+4
source

All Articles