title: Extract values from within strings in a list - python
body: <p>I have a list in my python code with the following structure:</p>
  
  <pre><code>file_info = ['{file:C:\\samples\\123.exe, directory:C:\\}','{file:C:\\samples\\345.exe, directory:C:\\}',...]
  </code></pre>
  
  <p>I want to extract just the file and directory values for every value of the list and print it. With the following code, I am able to extract the directory values:</p>
  
  <pre><code>for item in file_info:
  
      print item.split('directory:')[1].strip('}')
  </code></pre>
  
  <p>But I am not able to figure out a way to extract the 'file' values. The following doesn't work:</p>
  
  <pre><code>print item.split('file:')[1].strip(', directory:C:\}')
  </code></pre>
  
  <p>Suggestions? If there is any better method to extract the file and directory values other than this, that would be great too. Thanks in advance.</p>