I am new to regular expressions in Ruby.
The string looks something like http://www.site.com/media/pool/product_color_purple.jpg 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 prince_purple.jpg.
So I have:
colour = c.attr('src').match(/(.*)color_(.*).jpg/)
puts "Colour is #{colour}"
What colour returns is the string again, instead of the extracted bit, which is the colour. What is going wrong here?
matchreturnsMatchDataand "mtch[0] is equivalent to the special variable $&, and returns the entire matched string. mtch[1], mtch[2], and so on return the values of the matched backreferences" - ruby-doc.org/core/classes/MatchData.html