User:SignpostMarv Martin/is uuid comparison
regex
<php> function is_uuid_regex($string) { return (bool)preg_match( '/^([0-9a-f]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12})$/S' ,$string); } </php>
no regex
<php> function is_uuid_no_regex($string) { $match = true; if(strlen($string) !== 36) { $match = false; } else if(strpos($string,'-') !== 8) { $match = false; } else if(ctype_alnum(str_replace('-',,$string)) === false) { $match = false; } else if(strpos($string,'-',24) !== false) { $match = false; } else if(strpos($string,'-',9) !== 13) { $match = false; } else if(strpos($string,'-',13) !== 13) { $match = false; } else if(strpos($string,'-',14) !== 18) { $match = false; } else if(strpos($string,'-',18) !== 18) { $match = false; } else if(strpos($string,'-',19) !== 23) { $match = false; } else if(strpos($string,'-',23) !== 23) { $match = false; } return $match; } </php>