I need to find dates in several formats in the text. I have some regex like this:
# Detection of:
# 25/02/2014 or 25/02/14 or 25.02.14
regex = r'\b(0?[1-9]|[12]\d|3[01])[-/\._](0?[1-9]|1[012])[-/\._]((?:19|20)\d\d|\d\d)\b'
The problem is that it also matches type dates 25.02/14, which is not very good, because the separation character does not match.
I could, of course, make a few regular expressions with a different splitting character for each regular expression or do subsequent processing of the matching results, but I would prefer a complete solution using only one good regular expression. Is there any way to do this?
source
share