Advanced Date Matching with Regex - Including leap years
Video Statistics and Information
Channel: Taming Tech
Views: 3,825
Rating: undefined out of 5
Keywords: regex, regular expressions, date matching, python, php, powershell, javascript, regex validation, regexp, powershell regex, python regex, php regex
Id: BxwCbPdGhzs
Channel Id: undefined
Length: 57min 48sec (3468 seconds)
Published: Mon Jul 20 2020
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
Please don't use regexes to validate dates.
First, regexes are for matching text patterns, not checking numeric values of things. The things shown in this video are clever, but are terrible code. It's fine to find things that look like dates, but for actually validating things like days and months, a regex is not the right tool for the job.
Second, whatever language you are using already has date validation code that someone else has already written, tested and debugged. There's no need for you to write your own code to validate dates.
Probably a terrible idea to do something like this in practice, but it offers some very interesting techniques and practices in regex. It's hilariously brilliant.
Well done, thanks for the video. A fine example and explanation of what is possible using regexp that includes testing scenarios.
I work with regex most daily. There are many clever and simple (or not so much) solutions using it. But damn, don't do that for dates. I use it to validate date formats, or reformat them when they're a string, but that validation is just an overly complex format validation. It won't validate a date since it accept wrong values.
I do think there are a lot better examples on where to use that will be useful in a programmer's life.