in reply to hex-only regex
Your first regex might be better if you force it to match the whole string:
if ($hash =~ /^[0-9a-f]{32}$/i) { return(1); }
This way, it doesn't match a good hash that also has some other junk with it. My guess is that you may be checking the string's length separately, in which case this isn't really necessary, but it might be nice to consolidate those checks.
I don't see anything wrong with your other pattern.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: hex-only regex
by merlyn (Sage) on Jan 17, 2007 at 16:44 UTC | |
by jettero (Monsignor) on Jan 17, 2007 at 19:18 UTC | |
by Roy Johnson (Monsignor) on Jan 17, 2007 at 23:46 UTC |