title: Extract only the portion of a string between two regex patterns
body: <p>I've looked at <a href="https://stackoverflow.com/questions/12692667/python-regular-expression-extract-text-between-patterns">this question</a> and although the answer solves the OP's problem it doesn't actually answer the question. How can I extract a section of a given string when only the pattern before and after the relevant section are known?</p>
  
  <p>For example if I had a string like this:</p>
  
  <p><code>"Hi, this is a string where only values = { 000.10, 2.00, 5.0, 10.0 } are important</code></p>
  
  <p>And given this string I need to extract specifically <code>000.10, 2.00, 5.0, 10.0</code>. I don't know how many numbers there will be or their format, or even how many spaces there are in between them, but I know that <code>values = {</code> and <code>}</code> will be at the start and end.</p>
  
  <p>Using a regular expression I can find <code>values = { 000.10, 2.00, 5.0, 10.0 }</code> by doing:</p>
  
  <pre><code>import re
  
  string = "Hi, this is a string where only values = { 000.10, 2.00, 5.0, 10.0 } are important"
  
  match = re.search(r'values\s=\s\{.+}\s', string)
  if match:
      print match.group()
  else:
      print "Could not find a match..."
  </code></pre>
  
  <p>Which outputs:</p>
  
  <p><code>values = { 000.10, 2.00, 5.0, 10.0 }</code></p>
  
  <p>So how can I get only the text between the patterns <code>r'values\s=\s\{</code> and <code>\}\s</code>?</p>
  
  <p>I know that I could just replace the starting and end patterns with empty strings like this:</p>
  
  <p><code>match.group().replace('values = { ', '').replace(' } ', '')</code></p>
  
  <p>but is there a way to incorporate the fact that I only want the result between two patterns in the regular expression itself?</p>
  
  <p>Hopefully this question makes sense. Any answers would be appreciated.</p>