Reformat MM/DD/YYYY as YYYY-MM-DD
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
Rewrite every date written MM/DD/YYYY as YYYY-MM-DD. Leave everything else unchanged.
What this exercise teaches
(\d{2})/(\d{2})/(\d{4}) with the replacement $3-$1-$2 and the g flag reorders every date on the line.
A hint if you get stuck
Capture the three parts, then put them back in a new order with $1, $2 and $3 in the replacement.
This exercise is part of Pro
Pro unlocks all 52 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.
You create a free account first, so Pro is attached to it.
Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.