in reply to Regular expression for hexadecimal number
Something like....
/0x(?-i:[\da-f]{1,4})/... should do the trick. Curlies are pretty slow, relatively speaking, though. You will achieve approximately equivalent results with
/0x(?-i:[\da-f]+)/except that this will also match "0xdeadbeefcafe" and the like (which might be considered a feature).
Note that you do not want to use, as suggested elsewhere in this thread:
/0x[\da-f]{1,4}/i # or /0x[\da-f]+/i...since that would allow 0X2a (note the uppercase X) which is not a legal hexadecimal definition.
• another intruder with the mooring in the heart of the Perl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regular expression for hexadecimal number
by amarquis (Curate) on Jul 30, 2007 at 14:54 UTC | |
by radiantmatrix (Parson) on Jul 30, 2007 at 15:13 UTC |