title: How to return the substring of a string between two strings in Ruby?
body: <p>How would I return the string between two string markers of a string in Ruby?</p>
  
  <p>For example I have:</p>
  
  <ul>
  <li><code>input_string</code> </li>
  <li><code>str1_markerstring</code></li>
  <li><code>str2_markerstring</code></li>
  </ul>
  
  <p>Want to do something like:  </p>
  
  <pre><code>input_string.string_between_markers(str1_markerstring, str2_markerString)
  </code></pre>
  
  <p>Example text:</p>
  
  <pre><code>s
  # =&gt; "Charges for the period 2012-01-28 00:00:00 to 2012-02-27 23:59:59:&lt;br&gt;\nAny Network Cap remaining: $366.550&lt;br&gt;International Cap remaining: $0.000"
  str1_markerstring
  # =&gt; "Charges for the period"
  str2_markerstring
  # =&gt; "Any Network Cap"
  s[/#{str1_markerstring}(.*?)#{str2_markerstring}/, 1]
  # =&gt; nil  # IE DIDN'T WORK IN THIS CASE
  </code></pre>
  
  <p>Using Ruby 1.9.3.</p>