Regular expression for [a-zA-Z]
Asked Answered
W

1

5

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.

Wist answered 7/5, 2015 at 20:12 Comment(3)
Why can't you use [a-zA-Z]?Sadomasochism
[[:alpha:]]Panpipe
I will explain my question abd i will ask you to forgive my terrible English. I am building an engine to recognize regular expressions in assembly (8086) for school project. And i want to know if there is any shortcut for the only the letters a-z and A-Z with no other letters.Wist
L
7

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.

Lunt answered 7/5, 2015 at 20:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.