simplify regular expressions

Hi can anyone help me with how to simplify this regular expression
[ABCDE]

---------- Post updated at 09:16 PM ---------- Previous update was at 09:11 PM ----------

IS THIS RIGHT [A-E]

?

Yes Your Correct

POSIX expression
[[:alpha:]]

That's not the same as the OP's regex.
[:alpha:] is a POSIX character class for alphabetic characters. So the regex [[:alpha:]] matches a single character in the range a-z or A-Z.

$
$ # lower case single alphabetic character
$ echo "q" | grep -E "[[:alpha:]]"
q
$
$ # upper case single alphabetic character
$ echo "Q" | grep -E "[[:alpha:]]"
Q
$

[ABCDE] or [A-E] is a single character that is either A, or B, or C, or D, or E. So it will fail for both the examples shown above -

$
$ # fails for any lower case alphabetic character (because of the case)
$ echo "q" | grep -E "[A-E]"
$
$ # even if it is in the range a-e
$ echo "d" | grep -E "[A-E]"
$
$ # fails for any upper case alphabetic character that is not in the range A-E
$ echo "Q" | grep -E "[A-E]"
$

tyler_durden