5 kyu
validDate Regex
887 of 1,843wthit56
Description:
Your task is to write a regular expression (regex) that will match a string only if it contains at least one valid date, in the format [mm-dd]
(that is, a two-digit month, followed by a dash, followed by a two-digit date, surrounded by square brackets).
You should assume the year in question is not a leap year. Therefore, the number of days each month should have are as follows:
- 1. January - 31 days
- 2. February - 28 days (leap years are ignored)
- 3. March - 31 days
- 4. April - 30 days
- 5. May - 31 days
- 6. June - 30 days
- 7. July - 31 days
- 8. August - 31 days
- 9. September - 30 days
- 10. October - 31 days
- 11. November - 30 days
- 12. December - 31 days
All text outside a valid date can be ignored, including other invalid dates.
For example:
"[01-23]" // January 23rd is a valid date
"[02-31]" // February 31st is an invalid date
"[02-16]" // valid
"[ 6-03]" // invalid format
"ignored [08-11] ignored" // valid
"[3] [12-04] [09-tenth]" // December 4th is a valid date
Date Time
Regular Expressions
Fundamentals
Similar Kata:
Stats:
Created | Dec 14, 2014 |
Published | Dec 14, 2014 |
Warriors Trained | 7753 |
Total Skips | 2505 |
Total Code Submissions | 13054 |
Total Times Completed | 1843 |
JavaScript Completions | 887 |
Python Completions | 835 |
Ruby Completions | 178 |
CoffeeScript Completions | 11 |
Total Stars | 175 |
% of votes with a positive feedback rating | 87% of 313 |
Total "Very Satisfied" Votes | 246 |
Total "Somewhat Satisfied" Votes | 55 |
Total "Not Satisfied" Votes | 12 |