Java Programming
Accenture Technical PrimermediumJava Programming05 Regular Expression

What is the regular expression to match any date in the format "yyyy-mm-dd" in a string?

Answer options

A
\d{4}-\d{2}-\d{2}
B
\d{2}/\d{2}/\d{4}
C
[0-9]{4}.[0-9]{2}.[0-9]{2}
D
\d{4}\d{2}\d{2}

Correct answer: \d{4}-\d{2}-\d{2}

Explanation

Quick AnswerThe correct answer is \d{4}-\d{2}-\d{2} because it directly addresses the core logic of Java Programming.

The pattern \d{4}-\d{2}-\d{2} matches yyyy-mm-dd format dates.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

PrimerPrep has 1400+ practice questions, 2026 simulations and coding hands-on — all free.

Watch Walkthroughs!