May 29, 2006 at 6:43 am
· Filed under PHP Community
can someone tell me why my preg_match wont work? if(preg_match("/[a-z0-9]/i",$_POST['hash']))
rab_: what 'wont work' ?
syc, it supposed to only allow a-z and 0-9
^[a-z0-9]+$
Although you may want to allow A-Z as well
In which case you could just use if (ctype_alnum(…))
he has /i
oh
Yeah, then just use ctype_alnum
if you're testing for hash
you would only want a-f
Depends on the hash 
well, i assume md5
so /[a-z0-9/i wont work?
that will match if ANYTHING is a-z or 0-9
ohh
rab_: Use ctype_alnum()
k
Unless you do infact want just a-f
In which case ^[a-f0-9]+$
thanks
and all md5's are 32 characters in hex
So you could do ^[a-f0-9]{32}$
What do you guys do.. "if ($id) { } else { }" or "if (!$id) { } else { }" .. default is when there is no id specified.. which if else order do you use?
implement, this comes back No ending delimiter '^' found in /home/rab/www/hash.php on line 140
rab_: Er, I didn't put the delimiters in. You still need the // around it
ah
sorry, im horrible with these things like regexes
Permalink