Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Proper regular expression to find datetime in spanish

I am trying to write a regex to find a date in spanish de format is:

blabla4 de diciembre de 2018blabla

So I know I need to look for:

  • 1 or 2 digits (in case date has two)
  • blank space
  • exact characters 'de'
  • blank space
  • 1 to * characters between a-z
  • blank space
  • excact characters 'de'
  • blank space
  • exactly 4 digits

re.search("\d{1,2} de [a-z]+ de \d{4}")

What am I missing?

Examples:

  • mauricio2 de abril de 2016
  • belice12 de enero de 2018
  • australia1 de septiembre de 2015

Comments