Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Regular expression for hexadecimal number

by radiantmatrix (Parson)
on Jul 30, 2007 at 15:18 UTC ( [id://629593]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://629593]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-19 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found