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.

Save your patterns across devices.
/\d{4}-\d{2}-\d{2}/valid ✓

One sample per line. Tested live on the JavaScript engine — other flavors are validated and flagged for differences, not executed.

No samples.

Related regex recipes