Which of the following hexadecimal constants match the regular expression given? (0x[0-9A-F]+)
- (A)
0x4C5
- (B)
0x50b
- (C)
04A
- (D)
0x
Which of the following hexadecimal constants match the regular expression given? (0x[0-9A-F]+)
0x4C5
0x50b
04A
0x
ANSWER
Only option (A), 0x4C5, matches the expression.
Official answer: ASource: ISRO's final answer key of 15 May 2026
The expression 0x[0-9A-F]+ is the literal prefix 0x, followed by one or more characters, each of which is a digit 0-9 or an uppercase letter A-F.
The character class [0-9A-F] is case-sensitive, so lowercase letters a-f are not in it.
The + requires at least one character after the prefix, so the prefix alone is not enough.
(a) 0x4C5: prefix 0x, then 4, C, 5, all in the class. It matches.
(b) 0x50b: the last character b is lowercase, so it is not in [0-9A-F]. It does not match.
(c) 04A: it begins with 04, not the literal 0x. It does not match.
(d) 0x: nothing follows the prefix, so + is not satisfied. It does not match.
Only (a) matches.
KEY IDEA
Read a regular expression piece by piece: literal prefix, character class (case-sensitive), then the quantifier + meaning at least one character.
WATCH OUT FOR
Treating [0-9A-F] as if it also accepted lowercase hex digits (so choosing 0x50b), or accepting the bare prefix 0x although + demands at least one digit.
From the ISRO CS 2025 paper. Every question of this paper · The full paper (PDF, ISRO) · All 5 ISRO Finite automata questions, with notes