Regex for date matching (YYYY-MM-DD) in JavaScript

ISO dates (YYYY-MM-DD) are the safest interchange format. This pattern matches the shape; combine with a real date check for true validity. Test it below.

Working example
/\d{4}-\d{2}-\d{2}/

Try it live

The pattern and sample strings below are pre-loaded. Edit anything, or describe a variation in plain English and generate your own.

/\d{4}-\d{2}-\d{2}/valid ✓

Tested live on the JavaScript engine. Other flavors are validated and flagged for differences, not executed.

No samples.

Related regex recipes