title: Python:Extracting dates from a string and put into a list
body: <p>I have a string like this:</p>
  
  <pre><code>   old_ActNacd_2016-12-21_07-09-08.txt:100:2016-12-21 07:08:20 - [HSM   ]Handle Identity Request. Send Identity Response. timeout: 1550s
     old_ActNacd_2016-12-21_08-21-04.txt:52:2016-12-21 07:21:42 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
     old_ActNacd_2016-12-21_08-37-50.txt:49:2016-12-21 08:23:34 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
     old_ActNacd_2016-12-21_15-00-47.txt:49:2016-12-21 08:39:16 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
  </code></pre>
  
  <p>I tried doing like this:</p>
  
  <pre><code>  #creating list after taking the string out
    log_list = ostring.split('Handle Identity Request. Send Identity Response. timeout: 1550s')
      for itr in log_list:
          #getting the dates from the log_list
          match = re.search(r'\d{4}-\d{2}-\d{2}', itr)
          if match:
              date = datetime.strptime(match.group(), '%Y-%m-%d').date()
  </code></pre>
  
  <p>This process works fine, but i want to do only in one operation, rather than doing in two steps(splitting and matching)</p>
  
  <pre><code>  Note:-I want to create a list of dates from the string present between ":" and "space" in the string. I don't want the date present with "_ActNacd_" string.
  </code></pre>
  
  <p>So i will create a list which will contain dates:</p>
  
  <pre><code>['2016-12-21','2016-12-21', '2016-12-21', '2016-12-21']
  </code></pre>