Regex for ISO dates (YYYY-MM-DD)

Example pattern below—edit it or paste your own. All processing runs in your browser. For Python’s re module, switch flavor in the tool.

Flavor

Standard `RegExp` for explanation and preview.

g i m s u y d v (JavaScript)
Released 2024-03-15; legacy 1999-12-31 and bad 2025-02-30 still match shape.

Plain-English explanation

Flavor: JavaScript RegExp

Flags: g (find all matches)

a word boundary Then Match digit character (0–9), repeated exactly 4 times. Then Match the character "-". Then Match one of: (1) Match the character "0". Then Match one character from: characters from the character "1" to the character "9". OR (2) Match the character "1". Then Match one character from: characters from the character "0" to the character "2". Then Match the character "-". Then Match one of: (1) Match the character "0". Then Match one character from: characters from the character "1" to the character "9". OR (2) Match one character from: the character "1", the character "2". Then Match digit character (0–9). OR (3) Match the character "3". Then Match one character from: the character "0", the character "1". Then a word boundary

More examples

Back to RegExplain