title: How do I extract a substring from string using a regular expression?
body: <p>I am new to regular expressions in Ruby. </p>
  
  <p>The string looks something like <code>http://www.site.com/media/pool/product_color_purple.jpg</code> and I am trying to extract from this just the bit which has the colour in it. This can be a variable length, as some of the colours are like <code>prince_purple.jpg</code>.</p>
  
  <p>So I have:</p>
  
  <pre><code>colour = c.attr('src').match(/(.*)color_(.*).jpg/)
  puts "Colour is #{colour}"
  </code></pre>
  
  <p>What colour returns is the string again, instead of the extracted bit, which is the colour. What is going wrong here?</p>