Search for API Security Tests

GUID Regex Java Validator

GUID Regex Java 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


In Java, GUID (or UUID) validation is essential in many applications, particularly those involving database and record management. The java.util.regex package in Java can be used to validate GUIDs using regular expressions.

GUID Regex

Java regex for GUIDs follows the standard 8-4-4-4-12 format.

The GUID Regex Pattern

Pattern: ^[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}$

How to Validate GUIDs in Java?

To validate GUIDs in Java:

import java.util.regex.*;

public class GUIDValidator {
    public static boolean isValidGUID(String guid) {
        String regex = "^[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}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(guid);
        return matcher.matches();

    public static void main(String[] args) {
        String guid = "123e4567-e89b-12d3-a456-426655440000";
        System.out.println("Is GUID valid? " + isValidGUID(guid));

Uses of GUID Regex Validation

  1. System Identification: Validating GUIDs used as identifiers in software systems and applications.

  2. Data Consistency: Ensuring GUIDs maintain a consistent format across databases and APIs.


Java's robust regex capabilities facilitate effective GUID validation, ensuring adherence to the standard structure. For comprehensive validation, Akto's regex validator offers a tool for handling a variety of GUID formats and validation requirements.

Frequently asked questions

Why is GUID validation important in Java applications?

What is the standard format of a GUID in Java?

How can I validate a GUID using regular expressions in Java?

What are the potential use cases for GUID regex validation?

Is there a comprehensive tool available for handling different GUID formats and validation requirements?

GUID Regex Java Validator



GUID Regex Java Validator