title: Extract part of string according to pattern using regular expression Python
body: <p>I have a files that follow a specific format which look something like this:</p>
  
  <pre><code>test_0800_20180102_filepath.csv
  anotherone_0800_20180101_hello.csv
  </code></pre>
  
  <p>The numbers in the middle represent timestamps, so I would like to extract that information. I know that there is a specific pattern which will always be <code>_time_date_</code>, so essentially I want the part of the string that lies between the first and third underscores. I found some examples and somehow similar problems, but I am new to Python and I am having trouble adapting them.</p>
  
  <p>This is what I have implemented thus far:</p>
  
  <pre><code>datetime = re.search(r"\d+_(\d+)_", "test_0800_20180102_filepath.csv")
  </code></pre>
  
  <p>But the result I get is only the date part:</p>
  
  <pre><code>20180102
  </code></pre>
  
  <p>But what I actually need is:</p>
  
  <pre><code>0800_20180101
  </code></pre>