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.
In reply to Re: hex-only regex
by kyle
in thread hex-only regex
by dwhite20899
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |