EUI-64 (64-bit Extended Unique Identifier) Regex for Python
/^[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 Python. A rigorously tested regex reduces debugging time and protects your application from edge-case failures. The snippet below is ready to drop into your Python project — whether you're validating in a Django view, a FastAPI endpoint, or a standalone data processing script.
Python Implementation
# EUI-64 (64-bit Extended Unique Identifier)
# ReDoS-safe | RegexVault — Web & Network > MAC Address
import re
eui64_64bit_extended_unique_identifier_pattern = re.compile(r'^[0-9a-fA-F]{2}(?:[:-][0-9a-fA-F]{2}){7}$')
def validate_eui64_64bit_extended_unique_identifier(value: str) -> bool:
return bool(eui64_64bit_extended_unique_identifier_pattern.fullmatch(value))
# Example
print(validate_eui64_64bit_extended_unique_identifier("00:1a:2b:ff:fe:3c:4d:5e")) # TrueTest Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
00:1a:2b:ff:fe:3c:4d:5e | 00:1a:2b:3c:4d:5e |
FF-FF-FF-FF-FF-FF-FF-FF | 00:1a:2b:ff:fe:3c:4d |
02-50-56-ff-fe-a1-b2-c3 | 00:1a:2b:ff:fe:3c:4d:5e:6f |
A0:B1:C2:D3:E4:F5:06:07 | 00.1a.2b.ff.fe.3c.4d.5e |
00:00:00:ff:fe:00:00:00 | GG: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 Python developers because particularly important in Python web servers where CPU-bound regex operations can stall concurrent request handling. 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