Regexdrill

Level 3: Real-world validation Exercise 50 of 88 Free

ISO 8601 timestamps

A regex exercise from Regexdrill. Solve it with a pattern box with live highlighting in your browser, checked against hidden test strings, and it is checked the moment you submit.

The task

The whole line must match. Match a UTC timestamp like 2025-03-14T09:30:00Z: a date YYYY-MM-DD with a month from 01 to 12 and a day from 01 to 31, the capital letter T, a 24-hour time HH:MM:SS with hours 00 to 23 and minutes and seconds 00 to 59, and a final capital Z.

What this exercise teaches

Long patterns are short ones glued together: the date ranges, a literal T, the time ranges and a literal Z. Each number range is an alternation of digit shapes, like [01]\d|2[0-3] for the hours.

A hint if you get stuck

Reuse the ranges from the date and the 24-hour time exercises, and put the literal T between them and the literal Z at the end.

Try it now, free, no account needed

Every exercise on Regexdrill is free to try. Open it on the practice page, solve it, and get instant feedback with a hint. The worked solution opens once you solve it or after two tries.

Open this exercise

More exercises in Real-world validation