问题
I have a regular expression that matches English letters only, a [a-zA-Z] character class.
Is there any built-in regular expression for that? I mean something like \s or \w.
回答1:
You are asking for a shorthand class for English letters.
In case you are using POSIX-compliant regex, [:alpha:] is the "bracket expression" for [a-zA-Z] class. It is also supported by PCRE (Perl, PHP, Ruby...).
In Java, you can use \p{Alpha}.
In .NET, PCRE, Java, \p{L} is more than just [a-zA-Z] as it might include all Unicode letters. Still, it can be used to capture only letters.
来源:https://stackoverflow.com/questions/30110807/regular-expression-for-a-za-z