Jan-05-2018, 09:58 AM
here is nice site to test your regex patterns.
https://regex101.com/
you will see that your patterns do not match anything.
here is first pattern with some changes
https://regex101.com/r/dER5xH/1
note that using named groups could help and will make your code more readble
Actually, because you just want the year, pattern can be updated to catch all possible cases from your example
https://regex101.com/r/naVdDj/1
if you wish you may add named group, as is the entire match is what you need
https://regex101.com/
you will see that your patterns do not match anything.
here is first pattern with some changes
https://regex101.com/r/dER5xH/1
note that using named groups could help and will make your code more readble
Actually, because you just want the year, pattern can be updated to catch all possible cases from your example
r"199\d{1}|20\d{2}|\d{2}(?![/,\-\w ])"
https://regex101.com/r/naVdDj/1
if you wish you may add named group, as is the entire match is what you need