re = /~~TemplateStart~~[\s\S]+?~~TemplateEnd~~/
str = '<table cellSpacing="0" cellpadding="0" id="~~TableIDClass~~" class="ContainerTable">
<thead>
<tr class="header">
<td class="TableTitle">~~TableName~~</td>
</tr>
</thead>
<tbody class="~~TableIDClass~~ ClickableTableBody">
~~TemplateStart~~
<tr data-type="~~Data-Type~~" data-id="~~Data-ID~~" data-date="~~Data-Date~~" data-cost="~~Data-Cost~~" class="TableText clickable AddMee">
<td nowrap class="DateColumn">~~Date~~</td>
<td nowrap class="JarColumn"></td>
<td nowrap class="CategoryColumn">~~Category~~</td>
<td nowrap class="NotesColumn">~~Note~~</td>
<td nowrap class="CostColumn">~~DefaultCostDot~~$~~Cost~~</td>
</tr>
~~TemplateEnd~~
</tbody>
<tfoot>
<tr>
<td norap colspan="5">$<span class="TableTotal"></span></td>
</tr>
</tfoot>
</table> '
# Print the match result
str.match(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