Regular expression for [a-zA-Z] [closed]

对着背影说爱祢 提交于 2019-12-06 07:23:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!