re = /(?<=Bid\/Ask<\/TD>)[\s\S]*?(\d{2}\.\d{2})[\s\S]*?(\d{2}\.\d{2})[\s\S]*?(?=Low\/High<\/TD>)[\s\S]*?(\d{2}\.\d{2})[\s\S]*?(\d{2}\.\d{2})/m
str = ' <TR class="spot" bgColor=\'#f1f1f1\'>
<TD>Bid/Ask</TD> <TD
align=\'middle\' ><font
color=\'\'>15.73</font></TD>
<TD align=\'middle\' > </TD>
<TD align=\'middle\' ><font
color=\'\'>15.83</font></TD>
</TR>
<TR class="spot" bgColor=\'\'>
<TD>Low/High</TD> <TD
align=\'middle\' ><font
color=\'\'>15.51</font></TD>
<TD align=\'middle\' > </TD>
<TD align=\'middle\' ><font
color=\'\'>15.86</font></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