I have a text blob field in a MySQL column that contains HTML. I have to change some of the markup, so I figured I'll do it in a ruby script. Ruby is irrelevant here, but it would be nice to see an answer with it. The markup looks like the following:
<h5>foo</h5>
  <table>
    <tbody>
    </tbody>
  </table>
<h5>bar</h5>
  <table>
    <tbody>
    </tbody>
  </table>
<h5>meow</h5>
  <table>
    <tbody>
    </tbody>
  </table>
I need to change just the first <h5>foo</h5> block of each text to <h2>something_else</h2> while leaving the rest of the string alone.
Can't seem to get the proper PCRE regex, using Ruby.
 
     
     
     
    