Friday, August 27, 2010


Courtesy of Sun Web Learning Center

Which regex pattern finds both 0x4A and 0X5 from within a source file?

A 0[xX][a-fA-F0-9]
B 0[xX](a-fA-F0-9)
C 0[xX]([a-fA-F0-9])
D 0[xX]([a-fA-F0-9])+
E 0[xX]([a-fA-F0-9])?

D is correct. The + quantifier finds 1 or more occurrences of hex characters after an 0x is found.

No comments:

Post a Comment