Some time ago
You are interested in knowing when the tweets were posted. After reading a little bit more, you learn that dates are provided in different ways. You decide to extract the dates using .findall()
so you can normalize them afterwards to make them all look the same.
You realize that the dates are always presented in one of the following ways:
27 minutes ago
4 hours ago
23rd june 2018
1st september 2019 17:25
The list sentiment_analysis
containing the text of three tweets, as well as the re
module are already loaded in your session. You can use print()
to view the data in the IPython Shell.
Cet exercice fait partie du cours
Regular Expressions in Python
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Complete the for loop with a regex to find dates
for date in sentiment_analysis:
print(re.____(r"\d{____}\s____\s____", date))