Extracting date from a string in Python -


How can I remove a date from a string such as "Monkey 2010-07-10 Love Ban"? Thanks!

If the date is given in a certain form, then you just use a regular expression to remove You can date and "date time data.first": to parse the date:

  mail = re. Search (r '\ d {4} - \ d {2} - \ d {2}', 'text') Date = Date time. (), '% Y-% m-% d'). Date ()  

Otherwise, if the date given is an arbitrary form, you can not easily remove it.


Comments