Check if a string is a valid uuid

@param string $uuid The uuid to test
@return boolean
777455
public static function isValid($uuid)
    {
        $uuid = str_replace(array('urn:', 'uuid:', '{', '}'), '', $uuid);

        if ($uuid == self::NIL) {
            return true;
        }

        if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $uuid)) {
            return false;
        }
        return true;
    }
43208
public function upload($uuid = null)
    {
        if ($uuid) {
            // strip everything but valid UUID chars
            $uuid = preg_replace('/[^a-z\-0-9]/', '', $uuid);
        } else {
            $uuid = Text::uuid();
        }

        $options = [
            'upload_dir' => Configure::read('Attachments.tmpUploadsPath') . DS . $uuid . DS,
            // FIXME Make file paths configurable
            'accept_file_types' => Configure::read('Attachments.acceptedFileTypes')
        ];

        $uploadHandler = new \UploadHandler($options);
        exit;
    }
789228
private boolean isUUID(String uuid) {
        try {
            UUID.fromString(uuid);
            return true;
        } catch (Exception ex) {
            return false;
        }
    }
395200
public function show($uuid)
    {
        if ($uuid instanceof Service) {
            $uuid = $uuid->getUuid();
        }

        $response = $this->httpClient->get(
            $this->getResourceUrl($uuid),
            []
        );

        return ServiceResponse::createFromHttpResponse($response);
    }
663733
public function terminate($uuid)
    {
        if ($uuid instanceof Service) {
            $uuid = $uuid->getUuid();
        }

        $response = $this->httpClient->delete(
            $this->getResourceUrl($uuid),
            []
        );

        return ServiceResponse::createFromHttpResponse($response);
    }
183825
public function hasUserForUuid($uuid)
    {
        if ($this->accessControlManager->hasAccessEntityForUuid(self::ACCESS_ENTITY_TYPE, $uuid)) {
            return true;
        }
        
        return false;
    }
925079
def is_valid_uid(uid):
    
    pattern = r'^[A-Za-z][A-Za-z0-9]{10}$'
    if not isinstance(uid, string_types):
        return False
    return bool(re.compile(pattern).match(uid))
117323
public
    static function validate($uuid, $secret)
    {
        $uuidData = preg_replace('/[^0-9a-z]/i', '', $uuid);
        $uuidData = substr($uuidData, 8);

        $hash = hash_hmac(self::HASH_METHOD, $uuidData, $secret);
        $checksum = "b" . substr($hash, 0, 7);

        return $checksum == substr($uuid, 0, 8);
    }
30830
def _is_uuid(uuid):
    '''
    
    '''
    if uuid and list((len(x) for x in uuid.split('-'))) == [8, 4, 4, 4, 12]:
        return True
    return False
1108073
public static function toOptimized($uuid)
    {
        $uuid = preg_replace('/\-/', null, $uuid);
        return hex2bin(substr($uuid, 12, 4)) .
            hex2bin(substr($uuid, 8, 4)) .
            hex2bin(substr($uuid, 0, 8)) .
            hex2bin(substr($uuid, 16, 4)) .
            hex2bin(substr($uuid, 20));
    }
634514
def validate_uuid(value):
    

    if value and not isinstance(value, UUID):
        try:
            return UUID(str(value), version=4)
        except (AttributeError, ValueError):
            raise ValidationError('not a valid UUID')
    return value
844295
def valid_uuid(value):
    

    try:
        uuid.UUID(value, version=4)
        return True
    except (TypeError, ValueError, AttributeError):
        return False
631614
protected function makeUnique($uuid): string
    {
        $uniqueUUID = $uuid;
        $iteration = 0;
        while (!$this->validateUUID($uniqueUUID)) {
            $iteration++;
            $uniqueUUID = $this->generateUUID();
        }
        return $uniqueUUID;
    }
353162
public function reduce(string $uuid): string
    {
        $dictionaryLength = $this->dictionary->getLength();
        $uuidInt = $this->converter->fromHex($uuid);
        $output = '';

        while ($uuidInt->getValue() > 0) {
            $previousNumber = clone $uuidInt;
            $uuidInt = $uuidInt->divide($dictionaryLength);
            $digit = $previousNumber->mod($dictionaryLength);
            $output .= $this->dictionary->getCharAt((int) $digit->getValue());
        }

        return $output;
    }
70537
func IsValidUUID(uuid string) bool {
	r := regexp.MustCompile("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$")
	return r.MatchString(uuid)
}
177026
static protected function uuid()
		{
			// Use the random or the server name (if present) in the generation of UUID
			$base = md5(uniqid(rand(), true));

			// Mark as "random" UUID, set version
			$byte = hexdec( substr ($base, 12, 2));
			$byte = $byte & hexdec('0F');
			$byte = $byte | hexdec('40');
			$base = substr_replace($base, strtoupper (dechex ($byte)), 12, 2);

			// Set the variant
			$byte = hexdec (substr ($base, 16, 2));
			$byte = $byte & hexdec('3F');
			$byte = $byte | hexdec('80');
			$base = substr_replace($base, strtoupper (dechex ($byte)), 16, 2);

			// Format
			return strtolower(sprintf('%s-%s-%s-%s-%s', substr($base, 0, 8),	substr($base, 8, 4), substr($base, 12, 4), substr($base, 16, 4), substr($base, 20, 12)));
		}
1220209
public static final void uuid(String uuid)
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "uuid", uuid);

        _uuid = uuid;

        if (tc.isEntryEnabled())
            Tr.exit(tc, "uuid");
    }