Advertisement

Pattern library / Dates & Time

US Date Regex (MM/DD/YYYY)

American exports write 12/31/2026; European ones write the same numbers reversed. This pattern pins the US order — month first, both parts zero-padded, ranges enforced — and the pitfalls explain why 13/01/2026 proving wrong proves nothing about which side of the Atlantic your data came from.

The pattern
^(0[1-9]|1[0-2])/(0[1-9]|[12][0-9]|3[01])/[0-9]{4}$
Load this pattern into the tester →

How the pattern works

Test it: match & no-match examples

Every row is loaded straight into the tester — click Try to see the match live:

InputResultWhy
12/31/2026MatchDecember 31, US orderTry →
01/05/2026MatchJanuary 5, zero-paddedTry →
06/15/2026Matchday over 12 proves US orderTry →
13/01/2026No matchno month 13Try →
1/5/2026No matchunpadded — strict form wants 01/05 (loose variant in notes)Try →
31/12/2026No matchEuropean order lands day in the month slotTry →

Where to use it

JavaScript

const US = /^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/[0-9]{4}$/;
US.test('12/31/2026'); // true

Python (validate, then parse)

import re
US = r'^(0[1-9]|1[0-2])/(0[1-9]|[12][0-9]|3[01])/[0-9]{4}$'
bool(re.fullmatch(US, '12/31/2026'))  # True
from datetime import datetime
datetime.strptime('12/31/2026', '%m/%d/%Y')  # unambiguous parse

BigQuery (RE2)

WHERE REGEXP_CONTAINS(date_str, r'^(0[1-9]|1[0-2])/(0[1-9]|[12][0-9]|3[01])/[0-9]{4}$')

Common mistakes

Test this pattern on your own data
Paste it into the free tester with your real strings — nothing leaves your browser.
Open the regex tester →

FAQ

How do I validate mm/dd/yyyy in JavaScript?

const US = /^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/[0-9]{4}$/; then US.test('12/31/2026'). Both parts are zero-padded and range-limited.

How can I tell if a date is US or European format?

You cannot from the numbers alone when day ≤ 12 — 04/05/2026 is legal in both systems. Use the data source's locale, or normalize everything to ISO YYYY-MM-DD at ingestion.

What regex matches both US and European slash dates?

^(0[1-9]|1[0-2]|[12][0-9]|3[01])/(0[1-9]|1[0-2]|[12][0-9]|3[01])/[0-9]{4}$ — either order in either slot, meaning resolved in code. Prefer writing ISO instead.

Regex to Match Date (YYYY-MM-DD) — Test & Copy · ISO 8601 DateTime Regex — Match & Test Online · Extract Numbers from String — Regex + Examples

For GA4-specific patterns, see the GA4 regex cheat sheet, the page path regex guide, the event filter regex guide, the GA4 regex match types, the custom channel grouping guide and RE2 vs PCRE. Browse the full regex pattern library.