Saturday, August 14, 2010

Regex

Courtesy of education.oracle.com

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