Search for API Security Tests

UUID Regex Go Validator

UUID Regex Go Validator

Regex Tester Online tools to learn, build & test Regular Expression (RegEx/RegExp)
0 match
/ gm
Possible security issues
Match information

Regular Expression - Documentation

Regular Expression - Documentation


Universally Unique Identifiers (UUIDs) are widely used in software development for uniquely identifying information. The correct format of a UUID is essential for data integrity and uniqueness. A typical regex for UUID validation is


What is UUID Regex?

A UUID is a 128-bit number, represented as 32 hexadecimal characters, segmented into 5 groups.

The UUID Regex Pattern

The regex pattern for a standard UUID is:

  • This pattern checks the structure and specific version and variant bits.

How to Validate UUIDs Using Regex in Go?

Validating a UUID in Go with regex:

  1. Define the regex pattern for a valid UUID.

  2. Use the regexp package in Go to compile the regex pattern.

  3. Validate the UUID strings with the compiled regex.

package main

import (

func isValidUUID(uuid string) bool {
    // Define the regex pattern
    var uuidRegex = regexp.MustCompile(`^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$`)
    return uuidRegex.MatchString(uuid)

func main() {
    testUUID := "123e4567-e89b-12d3-a456-426614174000"
    fmt.Printf("Is '%s' a valid UUID? %t\n", testUUID, isValidUUID(testUUID))

Uses of UUID Regex Validation

UUID regex validation is important for:

  1. Unique Identification: Ensuring each UUID is unique and correctly formatted.

  2. Data Management: UUIDs are often used as primary keys in databases and for identifying objects in distributed systems.

  3. Consistency: Maintaining format consistency across various systems that utilize UUIDs.

What next?

Ensure UUID integrity in Go applications with appropriate regex patterns. Akto's validation tool can provide additional verification for optimal UUID handling.

Frequently asked questions

What is a UUID?

Why is the correct format of a UUID important?

What is the regex pattern for validating a UUID?

How can I validate UUIDs using regex in Go?

Why is UUID regex validation important?

UUID Regex Go Validator



UUID Regex Go Validator