re = /(\s*<script.*>)((\s|.)*)(<\/script\s*?>)/
str = '<script type="text/template" data-category="text" data-img-src="section-01.jpg" data-section-name="1">
<div class="zpsection" data-element-type="section">
<div class="zpcontainer">
<div class="zprow" data-element-type="row" data-column-ratio="12,12">
<div class="zpcol-md-12 zpcol-sm-12" data-element-type="column">
<div class="zpelement zpelem-heading" data-element-type="heading">
<h2 class="zpheading zpheading-align-center" data-editor="true">The face of the moon was in shadow</h2>
</div>
<div class="zpelement zpelem-text" data-element-type="text">
<div class="zptext zptext-align-center" data-editor="true">
<p>Almost before we knew it, we had left the ground. All their equipment and instruments are alive.Mist enveloped the ship three hours out from port. The spectacle before us was indeed sublime.A red flair silhouetted the jagged edge of a wing.</p>
</div>
</div>
<div class="zpelement zpelem-button" data-element-type="button">
<div class="zpbutton-container zpbutton-align-center"> <a href="javascript:;" class="zpbutton-wrapper zpbutton zpbutton-type-primary zpbutton-size-md"> <span class="zpbutton-content">Get Started Now</span> </a> </div>
</div>
</div>
</div>
</div>
</div>
</script>
'
# 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