Challenge: 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.
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.
Lösning
Tack för dina kommentarer!
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 6.67
Challenge: Extract Dates in Various Formats
Svep för att visa menyn
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.
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.
Lösning
Tack för dina kommentarer!
single