REGEXVAULT
Web & Network/MAC Address
ReDoS Checked

MAC OUI (Organizationally Unique Identifier) Regex for Python

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

All five implementations are free. Switch engines without signing in.

What this pattern does

This page provides a well-structured, multi-part regular expression for matching mac oui (organizationally 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

Python
# MAC OUI (Organizationally Unique Identifier)
# ReDoS-checked | RegexVault — Web & Network > MAC Address

import re

mac_oui_organizationally_unique_identifier_pattern = re.compile(r'^[0-9a-fA-F]{2}(?::[0-9a-fA-F]{2}){2}$')

def validate_mac_oui_organizationally_unique_identifier(value: str) -> bool:
    return bool(mac_oui_organizationally_unique_identifier_pattern.fullmatch(value))

# Example
print(validate_mac_oui_organizationally_unique_identifier("00:1a:2b"))  # True

Test Cases

Matches (Valid)
Rejects (Invalid)
00:1a:2b00:1a
FF:FF:FF00:1a:2b:3c
A0:B1:C200:1a:2b:3c:4d:5e
00:50:56GG:HH:II
DC:A6:32001a2b

When to use this pattern

This pattern is drawn from the Web & Network > MAC Address category and has been checked for ReDoS risk. 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

Locally administered bits (bit 1 of the first byte) indicate the MAC was not assigned by a manufacturer — check the second-least-significant bit of the first octet.

Technical Notes

00:50:56 is VMware, DC:A6:32 is Raspberry Pi Foundation. OUI lookup databases (IEEE public registry) can identify vendors from this prefix.

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Submissions join the review queue after automated validation.

Submit a Pattern