The regular expression that represents a single upper-case letter is [A-Z]. This is a character class that matches any one character from the range A to Z, which are the 26 upper-case letters of the English alphabet. A character class is enclosed in square brackets and can contain a list or a range of characters to match. For example, [abc] matches any one of the letters a, b, or c, and [0-9] matches any one digit from 0 to 9. The other options are not valid regular expressions for a single upper-case letter. The :UPPER: option is not a valid syntax for a character class, and it would be interpreted as a literal string of seven characters. The !a-z option is not a valid syntax for a negated character class, and it would be interpreted as a literal string of four characters. The %C option is not a valid syntax for a character class, and it would be interpreted as a literal string of two characters. The {AZ} option is not a valid syntax for a character class, and it would be interpreted as a literal string of four characters. The curly braces are used for interval expressions, which specify the number of repetitions of a character or a group of characters. For example, a{2,4} matches the letter a repeated two, three, or four times. References:
How to Use Regular Expressions (regexes) on Linux1
How to Use Regular Expressions (RegEx) on Linux2
A beginner’s guide to regular expressions with grep3
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit