classes

grep -E '^[A-Z][a-z]+$' names.txt

Ranges

[a-z] matches one lowercase letter [0-9] matches one digit [A-Za-z0-9_] matches a word character in POSIX

Negation

[^0-9] matches anything except a digit The caret negates only when it is first inside the brackets

Predefined classes

\d , \w , \s work in PCRE In POSIX ERE they are not standard Use explicit ranges when portability matters

Shorthand danger

A range like [A-z] includes characters between Z and a That is a bug that looks like a feature Check the ASCII table before trusting a range

Next

Quantifiers in 03 quantifiers

Posted