in reply to Validating Hex Numbers
Feed it any of these non-hex strings and they'll be validated.
and the list goes on.qw[ afg fA lA rA 0X ]
You need to make sure the entire string consists of only those characters, and in order to do that, you need anchors (notice I use \z instead of $)
The other thing you might have to check is the length of the string (should be even, even though 'AFF' might be considered '0AFF', whatever)./^[\da-f]+\z/i
update: thanks sauoq for tyepo catch ;)
|
MJD says you can't just make shit up and expect the computer to know what you mean, retardo! ** The Third rule of perl club is a statement of fact: pod is sexy. |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Validating Hex Numbers
by seattlejohn (Deacon) on Jan 09, 2003 at 01:11 UTC |