re = /<tr>\n\s*<td width="70"><strong>Released:<\/strong><\/td>\n\s*<td>(.*)<\/td>\n\s*<\/tr>\n\s*<tr>\n\s*<td width="70"><strong>Runtime:<\/strong><\/td>\n\s*<td>(.*)<\/td>\n\s*<\/tr>\n\s*<tr>\n\s*<td width="70"><strong>Genres:<\/strong><\/td>\n\s*<td><span class="movie_info_genres"><a\s[^<>]*>([^<>]*)<\/a>/m
str = '<tr>
<td width="70"><strong>Released:</strong></td>
<td>July 25, 2014</td>
</tr>
<tr>
<td width="70"><strong>Runtime:</strong></td>
<td>90 mins </td>
</tr>
<tr>
<td width="70"><strong>Genres:</strong></td>
<td><span class="movie_info_genres"><a href="/?genre=Action">Action</a> <a href="/?genre=Sci-Fi">Sci-Fi</a> </span></td>
</tr>
<tr>
<td width="70"><strong>Actors:</strong></td>
<td><span class="movie_info_actors">
<a href="/?actor_name= Analeigh Tipton "> Analeigh Tipton </a> <a href="/?actor_name= Morgan Freeman "> Morgan Freeman </a> <a href="/?actor_name= Scarlett Johansson "> Scarlett Johansson </a> <a href="/?actor_name=Min-sik Choi">Min-sik Choi</a> </span></td>
</tr>'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html