title: Python Regex to Parse String and Return Tuple
body: <p>I've been given some strings to work with. Each one represents a data set and consists of the data set's name and the associated statistics. They all have the following form:</p>
  
  <pre><code>s= "| 'TOMATOES_PICKED'                                  |       914 |       1397 |"
  </code></pre>
  
  <p>I'm trying to implement a function that will parse the string and return the name of the data set, the first number, and the second number. There are lots of these strings and each one has a different name and associated stats so I've figured the best way to do this is with regular expressions. Here's what I have so far:</p>
  
  <pre><code>def extract_data2(s):
      import re
      name=re.search('\'(.*?)\'',s).group(1)
      n1=re.search('\|(.*)\|',s)
      return(name,n1,)
  </code></pre>
  
  <p>So I've done a bit of reading on regular expressions and figured out how to return the name. For each of the strings that I'm working with, the name of the data set is bounded by ' ' so that's how I found the name. That part works fine. My problem is with getting the numbers. 
    What I'm thinking right now is to try to match a pattern that is preceded by a vertical bar ('|'), then anything (which is why I used .*), and followed by another vertical bar to try to get the first number. Does anyone know how I can do this in Python? 
    What I tried in the above code for the first number returns basically the whole string as my output, whereas I want to get just the number.
  -I am very new to programming so I apologize if this question seems rudimentary, but I have been reading and searching quite diligently for answers that are close to my case with no luck. I appreciate any help.
  The idea is that it will be able to:</p>
  
  <pre><code>return(name,n1,n2)
  </code></pre>
  
  <p>so that when the user inputs a string, it can just parse up the string and return the important information. I've noticed in my attempts to get the numbers so far that it will return the number as a string. Is there anyway to return n1 or n2 as just a number? Note that for some of the strings n1 and n2 could be either integers or have a decimal.</p>