EUI-64 (64-bit Extended Unique Identifier) Regex for Go
/^[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 Go. A rigorously tested regex reduces debugging time and protects your application from edge-case failures. The snippet below is ready to drop into your Go project — whether you're validating in a Gin handler, a gRPC service, or a command-line tool.
Go Implementation
// EUI-64 (64-bit Extended Unique Identifier)
// ReDoS-safe | RegexVault — Web & Network > MAC Address
package validation
import "regexp"
var eui6464bitExtendedUniqueIdentifierRe = regexp.MustCompile(`^[0-9a-fA-F]{2}(?:[:-][0-9a-fA-F]{2}){7}$`)
func ValidateEui6464bitExtendedUniqueIdentifier(s string) bool {
return eui6464bitExtendedUniqueIdentifierRe.MatchString(s)
}
// Example
// fmt.Println(ValidateEui6464bitExtendedUniqueIdentifier("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 Go developers because Go's RE2 engine is inherently safe from catastrophic backtracking, but this pattern has been additionally verified for correctness. 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