Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Extract Dates in Various Formats | Intermediate Regular Expressions
Python Regular Expressions

bookChallenge: Extract Dates in Various Formats

To strengthen your skills with grouping and quantifiers in regular expressions, you will now write a function to extract dates from text. The goal is to identify dates in the formats "YYYY-MM-DD" (such as 2024-06-15) and "DD/MM/YYYY" (such as 15/06/2024). Your function should scan a string and return all matching dates in a list. This exercise will help you practice using groups, quantifiers, and alternation to match multiple date formats reliably.

Tehtävä

Swipe to start coding

Your task is to create a function that finds all dates in a string. The dates can be in either the "YYYY-MM-DD" format or the "DD/MM/YYYY" format. Use the Python regular expressions module to identify and extract each date. Return a list of all dates found in the input string.

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 3
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

Awesome!

Completion rate improved to 6.67

bookChallenge: Extract Dates in Various Formats

Pyyhkäise näyttääksesi valikon

To strengthen your skills with grouping and quantifiers in regular expressions, you will now write a function to extract dates from text. The goal is to identify dates in the formats "YYYY-MM-DD" (such as 2024-06-15) and "DD/MM/YYYY" (such as 15/06/2024). Your function should scan a string and return all matching dates in a list. This exercise will help you practice using groups, quantifiers, and alternation to match multiple date formats reliably.

Tehtävä

Swipe to start coding

Your task is to create a function that finds all dates in a string. The dates can be in either the "YYYY-MM-DD" format or the "DD/MM/YYYY" format. Use the Python regular expressions module to identify and extract each date. Return a list of all dates found in the input string.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 3
single

single

some-alt