in reply to Regular expression for hexadecimal number

I'm curious about your actual requirement, because I'm not sure a regex is the way you want to go. If you have a hexadecimal value already, working with it as a number is pretty easy: using a regex is working with it as a string.

Consider:

my $hex_val = '0xCAFE'; if ( hex($hex_val) >= 0 && hex($hex_val) <= 0xFFFF ) { print "$hex_val is in range\n"; } else { print "$hex_val is out of range\n"; }

All this requires is use of the hex function.

<radiant.matrix>
Ramblings and references
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet