Page 1 of 1

preg_match

Posted: Wed Sep 23, 2009 9:28 am
by theS70RM
Hey guys,

im having a bit of trouble creating a regular expression to validate objectguid's.

They must be no more or less than 32 characters in length, and case insensitive HEX characters, ie a-z A-Z 0-9
here's the function im using but it's not right

Code: Select all

 
    function isGuid($guid){
 
        //doesnt work correctly
        return preg_match( '/[a-fA-F0-9]{32,32}/', $guid);
        
    }
 
 

this is valid:
"ca9bc7b5ff1a3345b3d8c5e09316015e"



Can anyone help me get the correct regular expression.

Thanks


Andy

Re: preg_match

Posted: Wed Sep 23, 2009 9:39 am
by Mark Baker
Start and end markers

Code: Select all

 
function isGuid($guid){
    //works correctly
    return preg_match( '/^[A-F0-9]{32}$/i', $guid);
}
 

Re: preg_match

Posted: Wed Sep 23, 2009 9:42 am
by theS70RM
ah knew it would be something stupid.

Thanks very much =)