Download Cheat sheet PDF 12 pages · syntax, editors, patterns, Unicode, performance, debugging
Pattern

Regex for MAC address (Cisco format)

Cisco-style dotted MAC: XXXX.XXXX.XXXX.

The MAC address (Cisco format) regex is ^[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}$ — copy it below, or open it in the explainer for a token-by-token breakdown.

The pattern

^[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}$
Try in explainer → Download cheat sheet ↓

What it matches

  • 001A.2B3C.4D5E
  • ffff.ffff.ffff
  • 0123.4567.89ab

What it doesn't match

  • 00:1A:2B:3C:4D:5E
  • 001A2B3C4D5E
  • 001A.2B3C.4D5

Notes & gotchas

Cisco uses dotted-three-quad MAC format (12 hex digits split into 3 groups of 4 with dots). Functionally equivalent to colon or hyphen separated forms.

Code in your language

Use the explainer's Code tab to generate ready-to-paste snippets in JavaScript, Python, Java, .NET, Go, Ruby, and PHP for this pattern.

Open in explainer →

Token-by-token breakdown

Every part of the pattern, left to right:

TokenMeaning
^start of string (or line in multiline mode)
[0-9a-fA-F]{4}exactly 4 times: any of: digits, a–f, A–F
\.literal “.”
[0-9a-fA-F]{4}exactly 4 times: any of: digits, a–f, A–F
\.literal “.”
[0-9a-fA-F]{4}exactly 4 times: any of: digits, a–f, A–F
$end of string (or line in multiline mode)

About this pattern

Identifying and validating user identity (names, contact info, IDs) is one of the most common reasons developers reach for regex. The pattern below handles the format check; for full validation always confirm against a source of truth (database, API, or document).

Quick usage in different languages

This exact pattern — with the correct escaping and idioms for each language:

  • JavaScript: /^[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}$/.test(value)
  • Python: re.match(r"^[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}$", value)
  • Java: Pattern.compile("^[0-9a-fA-F]{4}\\.[0-9a-fA-F]{4}\\.[0-9a-fA-F]{4}$").matcher(value).matches()
  • C# / .NET: Regex.IsMatch(value, @"^[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}$")
  • Go: regexp.MustCompile(`^[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}$`).MatchString(value)
  • Ruby: /^[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}$/.match?(value)
  • PHP: preg_match('~^[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}$~', $value)

The explainer’s Code tab regenerates these for any pattern you paste, and the downloadable cheat sheet bundles the breakdown, all seven snippets, and the pitfalls below onto one printable page.

Common pitfalls

  • Anchored to the whole string. This pattern uses ^ and $, so it requires the entire input to match. To find it inside a longer text, drop the anchors and use the global (g) flag.
  • Case sensitivity. Letter ranges are case-sensitive — use the i flag if the input case can vary.
  • Escape it correctly per language. In Java and JavaScript strings each backslash must be doubled (\\d); in Python, Go, and C# use raw/verbatim strings so the backslashes survive.
  • Validate beyond format. Matching the format doesn't guarantee the value is real. Confirm the mac address (cisco format) against a source of truth (database, API, or checksum) where it matters.

Related patterns

More patterns in the Identity & contact category:

See also

Browse all 300 patterns in the library, or open this regex in the interactive explainer to see a token-by-token breakdown, test against custom input, and generate code in seven languages.


← Back to all patterns