REGEXVAULTv2.0
Web & Network/MAC Address
Verified Safe

EUI-64 (64-bit Extended Unique Identifier) Regex for Java

/^[0-9a-fA-F]{2}(?:[:-][0-9a-fA-F]{2}){7}$/

What this pattern does

This page provides a well-structured, multi-part regular expression for matching eui-64 (64-bit extended unique identifier), ported and verified for Java. A rigorously tested regex reduces debugging time and protects your application from edge-case failures. The snippet below is ready to drop into your Java project — whether you're validating in a Spring Boot controller, a Jakarta EE service, or a standalone utility class.

Java Implementation

Java
// EUI-64 (64-bit Extended Unique Identifier)
// ReDoS-safe | RegexVault — Web & Network > MAC Address

import java.util.regex.Pattern;

public class Eui6464bitExtendedUniqueIdentifierValidator {
    private static final Pattern PATTERN =
        Pattern.compile("^[0-9a-fA-F]{2}(?:[:-][0-9a-fA-F]{2}){7}$");

    public static boolean validate(String input) {
        return PATTERN.matcher(input).matches();
    }

    // Example
    public static void main(String[] args) {
        System.out.println(validate("00:1a:2b:ff:fe:3c:4d:5e")); // true
    }
}

Test Cases

Matches (Valid)
Rejects (Invalid)
00:1a:2b:ff:fe:3c:4d:5e00:1a:2b:3c:4d:5e
FF-FF-FF-FF-FF-FF-FF-FF00:1a:2b:ff:fe:3c:4d
02-50-56-ff-fe-a1-b2-c300:1a:2b:ff:fe:3c:4d:5e:6f
A0:B1:C2:D3:E4:F5:06:0700.1a.2b.ff.fe.3c.4d.5e
00:00:00:ff:fe:00:00:00GG:HH:II:JJ:KK:LL:MM:NN

When to use this pattern

This pattern is drawn from the Web & Network > MAC Address category and carries a ReDoS-safe certification. That matters for Java developers because critical in Java applications since the JVM regex engine uses backtracking and is susceptible to ReDoS without careful pattern design. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.

Common Pitfalls

The separator must be consistent — do not mix colons and hyphens within a single address (though this pattern accepts either uniformly).

Technical Notes

EUI-64 is constructed from a MAC-48 by inserting ff:fe in the middle. The Universal/Local bit (bit 6 of octet 1) is flipped to form IPv6 Modified EUI-64 interface identifiers.

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.

Submit a Pattern