re = /(?:<iepigraph(?U).*>(?-U)(?:\s)*)+(?U)(.*)(?-U)(?:<\/iepigraph>)+/m
str = '<p class="p">Del podio del último Balón de Oro sólo sigue él en el Mundial y demostrando que es un crack absoluto.</p>
<p>
<b>
<span class="p">
<iepigraph class="epitit">
<iepigraph class="epitit">2. REGATE</iepigraph>
</iepigraph>
</span>
</b>
<span class="p"/>'
# 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