I am wondering how could I check if a date is within a string in Python. Imagine I have the following string:
str = 'yesterday it was a sunny day here in Boston; I went to the park and I played with 3 dogs; 2007-03-01'
I am trying to find a way to check if my string has a date on it but I couldn't find a way to do it, I thought of checking the numbers but that wouldn't work as I have many possibilities and numbers could be outside the date as in the string above.
What I have thought so far is to do something like:
str.split(';')
which would give me:
['yesterday it was a sunny day here in Boston', ' I went to the park and I played with 3 dogs', ' 2007-03-01']
But still I couldn't figure out a way to check if some of the elements in this new list is a date, as all of them seem to be strings. Is there any function in Python that allows to do so? Or could you give me any clue to achieve it?
I have also checked this Check if string has date, any format, but I am not trying to check if my string could be a date, but finding the date itself.